- if(peer_addr==0)
- throw InvalidState("Peer address not set");
- return *peer_addr;
-}
-
-void Socket::check_state(bool conn) const
-{
- if(handle==MSP_NET_INVALID_SOCKET_HANDLE)
- throw Exception("Socket is closed");
- if(conn && !connected)
- throw Exception("Socket is not connected");
+#ifndef WIN32
+ timeval tv = Time::rawtime_to_timeval(timeout.raw());
+ set_option(SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(timeval));
+ set_option(SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(timeval));
+#else
+ DWORD msecs = static_cast<DWORD>(timeout/Time::msec);
+ set_option(SOL_SOCKET, SO_RCVTIMEO, &msecs, sizeof(DWORD));
+ set_option(SOL_SOCKET, SO_SNDTIMEO, &msecs, sizeof(DWORD));
+#endif