diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-07-26 05:17:37 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-07-26 05:17:37 +0000 |
commit | 911e8d7e7f63e6e90814e82955bfaf26328afb19 (patch) | |
tree | 575a916f4616a0f865bff9928faa9be67a8c867e /src/wsocket.c | |
parent | d914007507a6a4ad3489cca19652af403fef7074 (diff) | |
download | luasocket-911e8d7e7f63e6e90814e82955bfaf26328afb19.tar.gz luasocket-911e8d7e7f63e6e90814e82955bfaf26328afb19.tar.bz2 luasocket-911e8d7e7f63e6e90814e82955bfaf26328afb19.zip |
Beta2 is out! Total timeout works on Windows.
Diffstat (limited to 'src/wsocket.c')
-rw-r--r-- | src/wsocket.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/wsocket.c b/src/wsocket.c index 1f1e99d..1b169ed 100644 --- a/src/wsocket.c +++ b/src/wsocket.c | |||
@@ -181,6 +181,8 @@ int sock_accept(p_sock ps, p_sock pa, SA *addr, socklen_t *len, p_tm tm) { | |||
181 | /*-------------------------------------------------------------------------*\ | 181 | /*-------------------------------------------------------------------------*\ |
182 | * Send with timeout | 182 | * Send with timeout |
183 | \*-------------------------------------------------------------------------*/ | 183 | \*-------------------------------------------------------------------------*/ |
184 | /* has to be larger than UDP_DATAGRAMSIZE !!!*/ | ||
185 | #define MAXCHUNK (64*1024) | ||
184 | int sock_send(p_sock ps, const char *data, size_t count, size_t *sent, p_tm tm) | 186 | int sock_send(p_sock ps, const char *data, size_t count, size_t *sent, p_tm tm) |
185 | { | 187 | { |
186 | int err; | 188 | int err; |
@@ -190,7 +192,9 @@ int sock_send(p_sock ps, const char *data, size_t count, size_t *sent, p_tm tm) | |||
190 | *sent = 0; | 192 | *sent = 0; |
191 | for ( ;; ) { | 193 | for ( ;; ) { |
192 | /* try to send something */ | 194 | /* try to send something */ |
193 | int put = send(*ps, data, (int) count, 0); | 195 | /* on windows, if you try to send 10MB, the OS will buffer EVERYTHING |
196 | * this can take an awful lot of time and we will end up blocked. */ | ||
197 | int put = send(*ps, data, (count < MAXCHUNK)? (int)count: MAXCHUNK, 0); | ||
194 | /* if we sent something, we are done */ | 198 | /* if we sent something, we are done */ |
195 | if (put > 0) { | 199 | if (put > 0) { |
196 | *sent = put; | 200 | *sent = put; |