We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › client - server problems with string
Page Index Toggle Pages: 1
client - server problems with string (Read 847 times)
client - server problems with string
Feb 22nd, 2007, 9:13pm
 
Hello,
I have strange problem with conection between two applications.
At first server application i send through myServer.write("sentence"). At other client application I recieve this string through myClient.readString().

Everything is working properly, but sometimes there is strange bug with this transition.

Mostly it is receiving normaly
sentence
sentence
sentence

but sometimes it looks like

sent
ence
s
entence
sentence

sentence
...

Please can you help me with it? I think that it is connected with fullfillness of transfering sockets but I dont know how to fix it.

I have WindowsXP Home edition system.

Thanks for your reply.



Re: client - server problems with string
Reply #1 - Feb 26th, 2007, 12:02pm
 
yep..

As my friend josh nimoy tells me ... "welcome to networking".

I'm not entirely sure myself as I'm also very green in net-coding but I've gotten the same problem as well.

The thing that I did to get around it was to not allow one of the apps (client or server, generally server) to not continue to the next step until all information is recieved properly. You could code some special character or string to represent an "end of line" of sorts.

It also helps if you write a system to lock-step the two although that might be slower.

I also suggest looking into this function:
http://processing.org/reference/libraries/net/Client_readStringUntil_.html

That should at least force a read until you see your end-line character, then strip the character out and you have a proper response.
Page Index Toggle Pages: 1