Pages: [1]   Go Down
Author Topic: Ethernet timeout?  (Read 1029 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone, i'm programming a server/client program. My arduino will be server. My question is if there is a time out in 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.

Global Moderator
Offline Offline
Shannon Member
Karma: 224
Posts: 13917
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
int c;
int cnt = 10;
c =;
} while ((-1 == c) && (cnt > 0));

and you could also use client.available() like in -


Rob Tillaart

Nederlandse sectie -,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: