This might be overkill if the communication needed is very basic. Also, there's something to be said for trying to use the built-in APIs of the language in order to see how they work, before trying to use a third-party package.

This might be overkill if the communication needed is very basic. Also, there's something to be said for trying to use the built-in APIs of the language in order to see how they work, before trying to use a third-party package.

That doesn't seem possible; if the Java client isn't able to connect to what you're telling it to connect to, or to send the data where you're telling it to send it, it should give an error message back. Unless your Java client is actually connecting to something else besides your C# server. (I'm focusing on the client because if the C# server works with a C# client, that indicates to me that the C# code is not what's causing the problem.) Could anything else be listening on port 2000?

Are you getting any output at all from the Java client? Note that as you've written the code here, for both the C# and the Java clients, there is no output to the console or anywhere else; the data read from the socket just gets stored in a variable. Is there more code you're not showing us?

Are you getting any output at all from the Java client Note that as you've written the code here, for both the C# and the Java clients, there is no output to the console or anywhere else; the data read from the socket just gets stored in a variable. Is there more code you're not showing us?

@user366312 you linked to a StackExchange thread, but that just has the same code you showed us here. Is that all the code there is? If so, your C# client would not output the string it receives from the server, so how do you know the C# client is working?

Also, we haven't seen the C# server code. What is the server supposed to do? Just echo back whatever it receives from the client? How does it do that?

@user366312 you linked to a StackExchange thread, but that just has the same code you showed us here. Is that all the code there is? If so, your C# client would not output the string it receives from the server, so how do you know the C# client is working?

Also, we haven't seen the C# server code. What is the server supposed to do? Just echo back whatever it receives from the client? How does it do that?

I have to implement simple key-value system. Each user can add to the system a new key-value pair. If the key has already existed, then the user who added this key should decide if the value should be updated.

Ok, so it looks like you are using ReadString and Write in the server code as well as the C# client code. So the responses in the StackExchange thread talking about how those functions use a format that is specific to C#, which Java does not know how to parse, might be relevant. For a multi-language implementation, it's best to use functions that read and write raw bytes, and have your code explicitly encode and decode them to whatever data types you want to use.

I'm also still confused about how you know the C# client is working with no console output.

I haven't read all details in this thread and may have missed if this has already been mentioned, but a common issue in general when writing and then reading on same socket (or blocking in other ways after writing) is to forget to flush the writer when you want the data to be sent. If the BinaryWriter supports buffered output it should also have a flush method you can call after writing your data to ensure it is pushed to the socket and sent.