AsyncSocket writeData Terminator
-
10-10-2019 - |
Question
I am porting a Java middleware client to objC. The java client uses the java stream.write and stream.flush at the end of the send. For the java client to send to the Echo server I need to add the stream.writeBytes("\r\n"); followed by stream.flush for the server to bounce the message back.
I am using the asyncsocket to send messages to the middleware's server, but after successfully opening the socket, the middleware does not react to a message sent using
[socket writeData:sendData withTimeout:-1 tag:0];
Also the middleware does not react to the message in the buffer when the socket is closed.
I am currently using
[socket writeData:[AsyncSocket CRLFData] withTimeout:-1 tag:0];
to flush the socket
Solution
I know this will not be the last time an assumption will come back to byte me.
I assumed that the java.io write was the same as BSD send or sendto, but from other posts, I am now assuming that the java.io.DataOutputStream is actually similar to NSMutableData and the write is appendData. Which means that writeInt is an Endian function and flush is the actual send/sendto command.