641129ea4df7d116ea619a10c02086b7cb446e00 kent Thu Apr 25 09:32:26 2013 -0700 Making new library function netWaitForData that is a minor refactoring of a private existing net.c function. diff --git src/inc/net.h src/inc/net.h index 1551782..58106d1 100644 --- src/inc/net.h +++ src/inc/net.h @@ -31,30 +31,34 @@ * IP address on the current machine if the current machine * has multiple IP addresses. */ int netAccept(int sd); /* Accept incoming connection from socket descriptor. */ int netAcceptFrom(int sd, unsigned char subnet[4]); /* Wait for incoming connection from socket descriptor * from IP address in subnet. Subnet is something * returned from netParseDottedQuad. */ FILE *netFileFromSocket(int socket); /* Wrap a FILE around socket. This should be fclose'd * and separately the socket close'd. */ +int netWaitForData(int sd, int microseconds); +/* Wait for descriptor to have some data to read, up to given number of + * number of microseconds. Returns amount of data there or zero if timed out. */ + void netBlockBrokenPipes(); /* Make it so a broken pipe doesn't kill us. */ size_t netReadAll(int sd, void *vBuf, size_t size); /* Read given number of bytes into buffer. * Don't give up on first read! */ int netMustReadAll(int sd, void *vBuf, size_t size); /* Read given number of bytes into buffer or die. * Don't give up if first read is short! */ boolean netSendString(int sd, char *s); /* Send a string down a socket - length byte first. */ boolean netSendLongString(int sd, char *s);