213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
**
** When bDontBlock is false, this function blocks until all N bytes
** have been read.
*/
size_t socket_receive(void *NotUsed, void *pContent, size_t N, int bDontBlock){
ssize_t got;
size_t total = 0;
int flags = bDontBlock ? MSG_DONTWAIT : 0;
while( N>0 ){
/* WinXP fails for large values of N. So limit it to 64KiB. */
got = recv(iSocket, pContent, N>65536 ? 65536 : N, flags);
if( got<=0 ) break;
total += (size_t)got;
N -= (size_t)got;
pContent = (void*)&((char*)pContent)[got];
|
|
>
>
>
|
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
**
** When bDontBlock is false, this function blocks until all N bytes
** have been read.
*/
size_t socket_receive(void *NotUsed, void *pContent, size_t N, int bDontBlock){
ssize_t got;
size_t total = 0;
int flags = 0;
#ifdef MSG_DONTWAIT
if( bDontBlock ) flags |= MSG_DONTWAIT;
#endif
while( N>0 ){
/* WinXP fails for large values of N. So limit it to 64KiB. */
got = recv(iSocket, pContent, N>65536 ? 65536 : N, flags);
if( got<=0 ) break;
total += (size_t)got;
N -= (size_t)got;
pContent = (void*)&((char*)pContent)[got];
|