Are sockets available in different programming languages ​​available?

Are sockets independent of a programming language ?

Can I save a server written in Java and a client written in C?

+6
java c sockets
source share
3 answers

That's right. Otherwise, it would be quite difficult to write a web browser and a web server, as an example ...

Of course, the data you exchange on a socket can be easier to read in one language than the other - for example, if you use Java DataOutputStream , on the other hand, it will be easier to control data from Java on the other end. But you can still read this data as the format is well documented.

If you put data absolutely platform-specific on the network, however, this complicates the work — for example, it would be difficult to use an object serialized with Java ObjectOutputStream from a platform other than Java.

But at the raw socket level, there is no concept of what programming language the source was written to.

+16
source share

A TCP socket communicates through a binary data stream. Many languages ​​have functions that have the top of this stack to simplify communication, but its simplest binary data.

If you want to communicate between two different languages, just avoid any kind of custom serialization of the languages ​​and stick to something simple, for example, passing simple strings back and forth.

+1
source share

Yes. it is the idea of ​​protocols (TCP / UDP) to set the rules for how a message should occur.

Mark this thread

0
source share

All Articles