| 359 | } |
| 360 | |
| 361 | static bool _SetNonBlocking |
| 362 | ( |
| 363 | SOCKET s, |
| 364 | bool nonblock |
| 365 | ) |
| 366 | { |
| 367 | if(!SOCKETVALID(s)) |
| 368 | return false; |
| 369 | #ifdef MINIHTTP_USE_POLARSSL |
| 370 | if(nonblock) |
| 371 | return net_set_nonblock(s) == 0; |
| 372 | else |
| 373 | return net_set_block(s) == 0; |
| 374 | #elif defined(_WIN32) |
| 375 | ULONG tmp = !!nonblock; |
| 376 | if(::ioctlsocket(s, FIONBIO, &tmp) == SOCKET_ERROR) |
| 377 | return false; |
| 378 | #else |
| 379 | int tmp = ::fcntl(s, F_GETFL); |
| 380 | if(tmp < 0) |
| 381 | return false; |
| 382 | if(::fcntl(s, F_SETFL, nonblock ? (tmp|O_NONBLOCK) : (tmp|=~O_NONBLOCK)) < 0) |
| 383 | return false; |
| 384 | #endif |
| 385 | return true; |
| 386 | } |
| 387 | |
| 388 | TcpSocket::TcpSocket |
| 389 | ( |
no outgoing calls
no test coverage detected