| 176 | |
| 177 | |
| 178 | uint Socket::receive(byte* buf, unsigned int sz) |
| 179 | { |
| 180 | wouldBlock_ = false; |
| 181 | |
| 182 | int recvd = recv_func_(ptr_, buf, sz); |
| 183 | |
| 184 | // idea to seperate error from would block by arnetheduck@gmail.com |
| 185 | if (recvd == -1) { |
| 186 | if (get_lastError() == SOCKET_EWOULDBLOCK || |
| 187 | get_lastError() == SOCKET_EAGAIN) { |
| 188 | wouldBlock_ = true; // would have blocked this time only |
| 189 | nonBlocking_ = true; // socket nonblocking, win32 only way to tell |
| 190 | return 0; |
| 191 | } |
| 192 | } |
| 193 | else if (recvd == 0) |
| 194 | return static_cast<uint>(-1); |
| 195 | |
| 196 | return recvd; |
| 197 | } |
| 198 | |
| 199 | |
| 200 | void Socket::shutDown(int how) |