Skip to content
Snippets Groups Projects
Commit faec2635 authored by rswindell's avatar rswindell
Browse files

Added timeout parameter to socket_check.

parent e1f4272c
No related branches found
No related tags found
No related merge requests found
......@@ -172,7 +172,7 @@ int recvfilesocket(int sock, int file, long *offset, long count)
/* Return true if connected, optionally sets *rd_p to true if read data available */
BOOL socket_check(SOCKET sock, BOOL* rd_p)
BOOL socket_check(SOCKET sock, BOOL* rd_p, DWORD timeout)
{
char ch;
int i,rd;
......@@ -188,8 +188,9 @@ BOOL socket_check(SOCKET sock, BOOL* rd_p)
FD_ZERO(&socket_set);
FD_SET(sock,&socket_set);
tv.tv_sec=0;
tv.tv_usec=0;
/* Convert timeout from ms to sec/usec */
tv.tv_sec=timeout/1000;
tv.tv_usec=(timeout%1000)*1000;
i=select(sock+1,&socket_set,NULL,NULL,&tv);
if(i==SOCKET_ERROR)
......
......@@ -125,7 +125,7 @@ extern "C" {
int sendfilesocket(int sock, int file, long *offset, long count);
int recvfilesocket(int sock, int file, long *offset, long count);
BOOL socket_check(SOCKET sock, BOOL* rd_p);
BOOL socket_check(SOCKET sock, BOOL* rd_p, DWORD timeout);
#ifdef __cplusplus
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment