File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,7 @@ module Network.Socket
143143 ,RecvIPv4TTL ,RecvIPv4TOS ,RecvIPv4PktInfo
144144 ,RecvIPv6HopLimit ,RecvIPv6TClass ,RecvIPv6PktInfo )
145145 , StructLinger (.. )
146+ , SocketTimeout (.. )
146147 , isSupportedSocketOption
147148 , whenSupported
148149 , getSocketOption
Original file line number Diff line number Diff line change @@ -232,6 +232,11 @@ sendManyTo s cs addr = do
232232--
233233-- For TCP sockets, a zero length return value means the peer has
234234-- closed its half side of the connection.
235+ --
236+ -- Currently, the 'recv' family is blocked on Windows because a proper
237+ -- IO manager is not implemented. To use with 'System.Timeout.timeout'
238+ -- on Windows, use 'Network.Socket.setSocketOption' with
239+ -- 'Network.Socket.RecvTimeOut' as well.
235240recv :: Socket -- ^ Connected socket
236241 -> Int -- ^ Maximum number of bytes to receive
237242 -> IO ByteString -- ^ Data received
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ module Network.Socket.Options (
2626 , getSockOpt
2727 , setSockOpt
2828 , StructLinger (.. )
29+ , SocketTimeout (.. )
2930 ) where
3031
3132import qualified Text.Read as P
@@ -251,14 +252,14 @@ pattern SendLowWater = SockOpt (#const SOL_SOCKET) (#const SO_SNDLOWAT)
251252#else
252253pattern SendLowWater = SockOpt (- 1 ) (- 1 )
253254#endif
254- -- | SO_RCVTIMEO: this does not work at this moment.
255+ -- | SO_RCVTIMEO: timeout in microseconds
255256pattern RecvTimeOut :: SocketOption
256257#ifdef SO_RCVTIMEO
257258pattern RecvTimeOut = SockOpt (# const SOL_SOCKET ) (# const SO_RCVTIMEO )
258259#else
259260pattern RecvTimeOut = SockOpt (- 1 ) (- 1 )
260261#endif
261- -- | SO_SNDTIMEO: this does not work at this moment.
262+ -- | SO_SNDTIMEO: timeout in microseconds
262263pattern SendTimeOut :: SocketOption
263264#ifdef SO_SNDTIMEO
264265pattern SendTimeOut = SockOpt (# const SOL_SOCKET ) (# const SO_SNDTIMEO )
@@ -481,6 +482,8 @@ instance Storable StructLinger where
481482----------------------------------------------------------------
482483
483484-- | Timeout in microseconds.
485+ -- This will be converted into struct timeval on Unix and
486+ -- DWORD (as milliseconds) on Windows.
484487newtype SocketTimeout = SocketTimeout Word32 deriving (Eq , Ord , Show )
485488
486489#if defined(mingw32_HOST_OS)
You can’t perform that action at this time.
0 commit comments