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

  • Context: Java 
  • Thread starter Thread starter user366312
  • Start date Start date
  • Tags Tags
    Binary Stream
Click For Summary

Discussion Overview

The discussion revolves around the challenges of sending a binary stream from a Java client to a C# server via TCP. Participants explore code implementations, potential issues, and alternative solutions, focusing on cross-language communication in a networked environment.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Experimental/applied

Main Points Raised

  • One participant shares C# client code and Java client code, noting that the Java code is not functioning as expected when communicating with the C# server.
  • Another participant suggests using ZeroMQ as a more robust solution for cross-language communication, providing example code for both C# and Java implementations.
  • Some participants express concern that ZeroMQ might be overkill for simple string communication, advocating for the use of built-in socket APIs instead.
  • There are inquiries about whether error messages are being received, with one participant noting that the Java client does not produce any error messages despite the communication failure.
  • Participants discuss the possibility that the Java client might be connecting to a different service or that the server might not be properly set up to receive connections on the specified port.
  • One participant suggests checking if the port is in use and mentions resources for identifying connected applications.
  • Another participant points out that the provided code does not output any data to the console, raising questions about the visibility of the communication process.
  • There is a request for clarification on the C# server's functionality and whether it is designed to echo received messages back to the client.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to solve the communication issue. Multiple competing views exist regarding the use of ZeroMQ versus built-in socket APIs, and uncertainty remains about the Java client's behavior and the C# server's implementation.

Contextual Notes

There are limitations regarding the visibility of output from both the Java and C# clients, as well as the lack of complete server code, which may affect the ability to diagnose the issue effectively.

  • #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   Reactions: 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