Loading src/posix/socket.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -70,3 +70,32 @@ void netplus::socket::setnonblocking(){ throw exception; } } void netplus::socket::setTimeout(int usec){ struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = usec; if (setsockopt (_Socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout) < 0){ char errstr[512]; strerror_r_netplus(errno,errstr,512); NetException exception; exception[NetException::Error] << "Could not set ClientSocket Recv timeout"<< errstr; throw exception; } if (setsockopt (_Socket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof timeout) < 0){ char errstr[512]; strerror_r_netplus(errno,errstr,512); NetException exception; exception[NetException::Error] << "Could not set ClientSocket Send timeout" << errstr; throw exception; } } src/socket.h +2 −2 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ namespace netplus { socket(); virtual ~socket(); void setnonblocking(); void setTimeout(int usec); virtual void accept(socket *csock)=0; virtual void bind()=0; Loading src/windows/socket.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -80,3 +80,7 @@ void netplus::socket::setnonblocking(){ } } void netplus::socket::setTimeout(int usec){ return; } Loading
src/posix/socket.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -70,3 +70,32 @@ void netplus::socket::setnonblocking(){ throw exception; } } void netplus::socket::setTimeout(int usec){ struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = usec; if (setsockopt (_Socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout) < 0){ char errstr[512]; strerror_r_netplus(errno,errstr,512); NetException exception; exception[NetException::Error] << "Could not set ClientSocket Recv timeout"<< errstr; throw exception; } if (setsockopt (_Socket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof timeout) < 0){ char errstr[512]; strerror_r_netplus(errno,errstr,512); NetException exception; exception[NetException::Error] << "Could not set ClientSocket Send timeout" << errstr; throw exception; } }
src/socket.h +2 −2 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ namespace netplus { socket(); virtual ~socket(); void setnonblocking(); void setTimeout(int usec); virtual void accept(socket *csock)=0; virtual void bind()=0; Loading
src/windows/socket.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -80,3 +80,7 @@ void netplus::socket::setnonblocking(){ } } void netplus::socket::setTimeout(int usec){ return; }