lectus Messages: 329 Registered: September 2006 Location: Brazil
Senior Member
nlneilson wrote on Fri, 07 December 2012 14:53
In the for() loop
sock.Put(FruitList[i] + '\n');
it looks like a sock.Put is called each time through the loop or is each char sent through the same connection and then '\n' is sent after all the char been sent?
or is it ch \n ch \n ch \n
Also does String GetLine() stop at each \n or is it looking for \0
Maybe String GetAll(int len) will read a bunch of data including several \n until the max len is reached or \0
My client is in U++ and it will send a string with several \n and it is parsed by the server in the Java app.
Each sock.Put sends a fruit name indexed as FruitList[i] with an ending \n.
It uses the same connection started by sock.Connect().
On the other side the sock.GetLine() reads everything until it finds \n and stores in a string without the \n.
Unless you're dealing with binary data I see no reason to not use strings ended with \n.