Java How to send a binary stream from Java-client to C#-server via Tcp?

  • Thread starter Thread starter user366312
  • Start date Start date
  • Tags Tags
    Binary Stream
Click For Summary
The discussion revolves around a user experiencing issues with a Java client not successfully communicating with a C# server over TCP. The user provided both C# and Java code snippets, indicating that while the C# server and clients work correctly, the Java client fails to send strings properly. Suggestions included using ZeroMQ for cross-language communication, which is recommended for microservices due to its robust handling of different programming languages.Participants highlighted the importance of using raw byte formats for data transfer between different languages, as the serialization methods in C# may not be compatible with Java. The conversation also touched on troubleshooting techniques, such as checking for error messages and ensuring that the correct ports are being used. Ultimately, the user resolved the issue by switching to raw data formats for both the C# and Java implementations, which allowed for successful communication. The discussion concluded with a recommendation to consider ZeroMQ for future projects, especially if they become more complex.
  • #31
PeterDonis said:
Why would he want to do that? He's not trying to transfer files.
Transferring a bit stream has the same inherent problems as transferring binary files. It is not dead easy - FTP has gone through several revisions.
 
  • Like
Likes jedishrfu
Technology news on Phys.org
  • #32
user366312 said:
Which console? C# or Java?

Both the C# will show that it works and the Java one will show something else that may be key to your problem.
 
  • #33
jedishrfu said:
Both the C# will show that it works and the Java one will show something else that may be key to your problem.

I have solved the problem. Never mind.

I thank all of you for your time and effort.
 
  • #34
That's great!

So what was the problem?
 
  • #35
jedishrfu said:
That's great!

So what was the problem?

There was difference in r/w data format.

I am now using raw data format on both ends. I am using byte arrays.
 
  • #36
Svein said:
Transferring a bit stream has the same inherent problems as transferring binary files

It has some of the same inherent problems, yes. But those problems are lower level than the application/protocol level. At the application/protocol level, FTP is specialized for transferring files (which don't have to be binary, FTP has a text mode as well--not that I would recommend using it, but it has one :wink:). And actually it's not a very good protocol for transferring files, since it requires two TCP connections instead of one and coordination between the two connections (control and data) is clunky.
 
  • #37
user366312 said:
There was difference in r/w data format.

I am now using raw data format on both ends. I am using bye arrays.

If this work gets more involved then you might want to consider zeromq.

Its very popular for communications between disparate programs in a microservices environment, has several multi-program architectures depending on the problem, and you get extra capability that might prove useful in the future.
 
  • #38
jedishrfu said:
If this work gets more involved then you might want to consider zeromq.

Its very popular for communications between disparate programs in a microservices environment, has several multi-program architectures depending on the problem, and you get extra capability that might prove useful in the future.

ZeroMQ is good for professional solutions. I doing a semester project.
 
  • #39
user366312 said:
ZeroMQ is good for professional solutions. I doing a semester project.

But you could put it on your resume sometimes these little things make a big difference.
 
  • #40
jedishrfu said:
But you could put it on your resume sometimes these little things make a big difference.
Okay. Thanks for the advice. I will look into that.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
13K