✅ Send Integer over TCP from Java to C#
Im trying to send an integer value from a java program to my c# program, for some reason the received byte[] is always empty?
12 Replies
I have also tried to do it with a binary reader like this but the integer is still 0
how are
outputStream
in the Java and client
in the C# created?I'm not familiar with Java sockets
Do they require you to explicitly connect?
(Sorry for the delay, was eating lunch)
as far as i know creating the socket in java is the connect itself
oh it does
(ew)
so
hm
that looks like it should work...
so, TcpListener/TcpClient are kinda notoriously janky, does it work if you just use sockets directly?
i could try that but i dont think the socket / stream creation itself is the problem, i have already transferred other data with them but when using the DataOutputStream the writeInt method doesnt seem to do anything
hm
so on the java side
im not sure if the problem is on the java side thats the thing xd
maybe it is being sent correctly but im just receiving wrong
hm
are you sure the C# side is listening before the Java side tries to connect?
yes i have debugged it several times, i have also tried sending the int as bytes but the value i get after converting the received bytes it into an integer is way off from what it should be