long connection:: read ( char* buf, long num ) { long status; while (true) { status = recv(connection_socket,buf,num,0); if (status == -1) { // if recv was interupted then try again if (errno == EINTR) continue; else { if (sd_called()) return SHUTDOWN; else return OTHER_ERROR; } } else if (status == 0 && sd_called()) { return SHUTDOWN; } return status; } // while (true) }
long connection:: read ( char* buf, long num, unsigned long timeout ) { if (readable(timeout) == false) return TIMEOUT; const long max_recv_length = 1024*1024*100; // Make sure to cap the max value num can take on so that if it is // really large (it might be big on 64bit platforms) so that the OS // can't possibly get upset about it being large. const long length = std::min(max_recv_length, num); long status = recv(connection_socket,buf,length,0); if (status == SOCKET_ERROR) { // if this error is the result of a shutdown call then return SHUTDOWN if (sd_called()) return SHUTDOWN; else return OTHER_ERROR; } else if (status == 0 && sd_called()) { return SHUTDOWN; } return status; }
long connection:: read ( char* buf, long num ) { long status = recv(connection_socket,buf,num,0); if (status == SOCKET_ERROR) { // if this error is the result of a shutdown call then return SHUTDOWN if (sd_called()) return SHUTDOWN; else return OTHER_ERROR; } else if (status == 0 && sd_called()) { return SHUTDOWN; } return status; }
long connection:: read ( char* buf, long num, unsigned long timeout ) { long status; const long max_recv_length = 1024*1024*100; if (readable(timeout) == false) return TIMEOUT; // Make sure to cap the max value num can take on so that if it is // really large (it might be big on 64bit platforms) so that the OS // can't possibly get upset about it being large. const long length = std::min(max_recv_length, num); status = recv(connection_socket,buf,length,0); if (status == -1) { // if recv was interupted then call this a timeout if (errno == EINTR) { return TIMEOUT; } else { if (sd_called()) return SHUTDOWN; else return OTHER_ERROR; } } else if (status == 0 && sd_called()) { return SHUTDOWN; } return status; }
long connection:: read ( char* buf, long num ) { long status; const long max_recv_length = 1024*1024*100; while (true) { // Make sure to cap the max value num can take on so that if it is // really large (it might be big on 64bit platforms) so that the OS // can't possibly get upset about it being large. const long length = std::min(max_recv_length, num); status = recv(connection_socket,buf,length,0); if (status == -1) { // if recv was interupted then try again if (errno == EINTR) continue; else { if (sd_called()) return SHUTDOWN; else return OTHER_ERROR; } } else if (status == 0 && sd_called()) { return SHUTDOWN; } return status; } // while (true) }