Go Down

Topic: Ethernet client.read() timeout? (Read 1 time) previous topic - next topic


Hello everyone, i'm programming a server/client program. My arduino will be server. My question is if there is a time out in client.read?if not how can i make one? my problem is here:

1)client sends 2 bytes
2)server(arduino) reads first, makes some checks to see what was the command
3)and then reads the second byte but sometimes read() returns -1

if i delay() the second read in server no problem!!! i need i time out in read to wait for reading unti a byte come but not forever.


If the timeout is not in the read you can build the read in a timeout construct. you need something like:
(not compiled or tested)
Code: [Select]
int c;
int cnt = 10;
c = client.read();
} while ((-1 == c) && (cnt > 0));

and you could also use client.available() like in - http://arduino.cc/en/Tutorial/WebServer

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131