More specifically, if a computer has a server (a java.net.ServerSocket
instance) can I connect to it using a C# System.Net.Sockets.Socket
instance?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- Sorting 3 numbers without branching [closed]
- Multiple sockets for clients to connect to
- How to maintain order of key-value in DataFrame sa
The main issue is that you need to be very careful with the encoding of the data that you send and receive. Here is a pair of programs that work together. The C# client sends a string, by first sending its length as an integer, and then sending the bytes of the string itself. The Java server reads the length, then reads the message and prints an output to the console. Then composes an echo message, computes its length, extracts the bytes and sends it back to the C# client. The client reads the length, the message and prints an output. There should be a way to avoid all the bitwise stuff, but honestly I'm a little rusty with this stuff, especially on the Java side.
A Java server:
A C# client: