开发者

Can sockets accessed in different programming languages communicate?

Are sockets开发者_开发知识库 programming language independent?

Can I keep the server written in Java and client written in C?


Absolutely. Otherwise it would be pretty hard to write a web browser and a web server, just as an example...

Of course, the data you communicate over the socket may be easier to read with one language than another - for example if you use Java's DataOutputStream, that's going to be easier to manage with Java at the other end to read the data. But you still could read that data, as the format is well documented.

If you put absolutely platform-specific data across the network though, that makes things harder - it would be tricky to use an object serialized with Java's ObjectOutputStream from a non-Java platform, for example.

But at the raw sockets level, there's no concept of which programming language the source happened to be written in.


A TCP Socket communicates via a binary stream of data. Many languages have features that sit a top this stack to make communication easier, but at its simplest its just binary data.

If you want to communicate between two different languages just avoid any custom serialization of the languages and stick with something simple like passing simple strings back and forth.


Yes. thats the idea of the protocols(TCP/UDP) to set the rules how the communication should occure.

Check this thread

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜