#Problem of tcp communication between rust server and java client

27 messages · Page 1 of 1 (latest)

versed jolt
#

Sorry to hijack, but this seems tangent to what I'm working on. Is there a way to do "AES/CTR/NOPADDING" from Java(if you don't know what it means, then you may not know enough about Java to help) in rust? There is a ctr crate, but I don't know is I'm to use the 128bit version?

viral cape
#

Hi, I have a problem:
I'm trying to make an application in 2 parts : a rust server and a java client that have to communicate with each other, I can make the communication from java to rust, but not the other way around, I don't have any error or log, it just doesn't work.
I don't know from which side the problem comes

true venture
viral cape
#

It doesn't seem to work ...

#

it's possible that the problem comes from java

#

I tried that too and no

bold flume
#

No, binding to 0.0.0.0 is correct

#

127.0.0.1 will only allow connections from the same machine I think

bold flume
viral cape
#

ok thanks 😄

#

i have a java.io.EOFException on the client

bold flume
#

makes sense

viral cape
#

and the server writes well

bold flume
#

idk Java well enough to really understand what it’s doing

viral cape
#

ok, thanks anyway, I'll go ask elsewhere

#

if someone else has an answer, I would appreciate it 😄

#

please ping me to answer

plush swan
#

@viral cape

writer.write_all(b"test\0");
viral cape
#

okay

#

I try this afternoon

copper trench
#

your problem is a java problem, not a rust problem

#

I think readUTF expects a 16 bit length to precede the string

#

also, despite the name, readUTF does not use utf8 encoding like rust does

#

it uses some really crazy encoding where 0 is encoded with two bytes, and the encoded values aren't unicode scalars but rather utf16 codepoints, which are decoded again to get the actual string; that is, surrogate pairs are encoded as two values instead of one like actual utf8 does

#

oh, you had writeUTF but not readUTF. Well, the crazy encoding rules still apply. and who knows what DataInputStream does. But the rust code is sane, it's still the java side which is not just reading bytes