| 334 | // ---------------------------------------------------------------------------------------- |
| 335 | |
| 336 | long connection:: |
| 337 | read ( |
| 338 | char* buf, |
| 339 | long num |
| 340 | ) |
| 341 | { |
| 342 | const long max_recv_length = 1024*1024*100; |
| 343 | // Make sure to cap the max value num can take on so that if it is |
| 344 | // really large (it might be big on 64bit platforms) so that the OS |
| 345 | // can't possibly get upset about it being large. |
| 346 | const long length = std::min(max_recv_length, num); |
| 347 | long status = recv(connection_socket,buf,length,0); |
| 348 | if (status == SOCKET_ERROR) |
| 349 | { |
| 350 | // if this error is the result of a shutdown call then return SHUTDOWN |
| 351 | if (sd_called()) |
| 352 | return SHUTDOWN; |
| 353 | else |
| 354 | return OTHER_ERROR; |
| 355 | } |
| 356 | else if (status == 0 && sd_called()) |
| 357 | { |
| 358 | return SHUTDOWN; |
| 359 | } |
| 360 | return status; |
| 361 | } |
| 362 | |
| 363 | // ---------------------------------------------------------------------------------------- |
| 364 | |