Ethernet timeout?

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.

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 -