diff options
Diffstat (limited to 'xs_socket.h')
| -rw-r--r-- | xs_socket.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/xs_socket.h b/xs_socket.h index e4a18ec..a3fe6a4 100644 --- a/xs_socket.h +++ b/xs_socket.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #define _XS_SOCKET_H | 5 | #define _XS_SOCKET_H |
| 6 | 6 | ||
| 7 | int xs_socket_timeout(int s, float rto, float sto); | 7 | int xs_socket_timeout(int s, double rto, double sto); |
| 8 | int xs_socket_server(char *addr, int port); | 8 | int xs_socket_server(char *addr, int port); |
| 9 | FILE *xs_socket_accept(int rs); | 9 | FILE *xs_socket_accept(int rs); |
| 10 | 10 | ||
| @@ -16,7 +16,7 @@ FILE *xs_socket_accept(int rs); | |||
| 16 | #include <netinet/in.h> | 16 | #include <netinet/in.h> |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | int xs_socket_timeout(int s, float rto, float sto) | 19 | int xs_socket_timeout(int s, double rto, double sto) |
| 20 | /* sets the socket timeout in seconds */ | 20 | /* sets the socket timeout in seconds */ |
| 21 | { | 21 | { |
| 22 | struct timeval tv; | 22 | struct timeval tv; |
| @@ -24,14 +24,14 @@ int xs_socket_timeout(int s, float rto, float sto) | |||
| 24 | 24 | ||
| 25 | if (rto > 0.0) { | 25 | if (rto > 0.0) { |
| 26 | tv.tv_sec = (int)rto; | 26 | tv.tv_sec = (int)rto; |
| 27 | tv.tv_usec = (int)((rto - (float)(int)rto) * 1000000.0); | 27 | tv.tv_usec = (int)((rto - (double)(int)rto) * 1000000.0); |
| 28 | 28 | ||
| 29 | ret = setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); | 29 | ret = setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | if (sto > 0.0) { | 32 | if (sto > 0.0) { |
| 33 | tv.tv_sec = (int)sto; | 33 | tv.tv_sec = (int)sto; |
| 34 | tv.tv_usec = (int)((sto - (float)(int)sto) * 1000000.0); | 34 | tv.tv_usec = (int)((sto - (double)(int)sto) * 1000000.0); |
| 35 | 35 | ||
| 36 | ret = setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)); | 36 | ret = setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)); |
| 37 | } | 37 | } |