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
143
143
,RecvIPv4TTL ,RecvIPv4TOS ,RecvIPv4PktInfo
144
144
,RecvIPv6HopLimit ,RecvIPv6TClass ,RecvIPv6PktInfo )
145
145
, StructLinger (.. )
146
+ , SocketTimeout (.. )
146
147
, isSupportedSocketOption
147
148
, whenSupported
148
149
, getSocketOption
Original file line number Diff line number Diff line change @@ -232,6 +232,11 @@ sendManyTo s cs addr = do
232
232
--
233
233
-- For TCP sockets, a zero length return value means the peer has
234
234
-- 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.
235
240
recv :: Socket -- ^ Connected socket
236
241
-> Int -- ^ Maximum number of bytes to receive
237
242
-> IO ByteString -- ^ Data received
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ module Network.Socket.Options (
26
26
, getSockOpt
27
27
, setSockOpt
28
28
, StructLinger (.. )
29
+ , SocketTimeout (.. )
29
30
) where
30
31
31
32
import qualified Text.Read as P
@@ -251,14 +252,14 @@ pattern SendLowWater = SockOpt (#const SOL_SOCKET) (#const SO_SNDLOWAT)
251
252
#else
252
253
pattern SendLowWater = SockOpt (- 1 ) (- 1 )
253
254
#endif
254
- -- | SO_RCVTIMEO: this does not work at this moment.
255
+ -- | SO_RCVTIMEO: timeout in microseconds
255
256
pattern RecvTimeOut :: SocketOption
256
257
#ifdef SO_RCVTIMEO
257
258
pattern RecvTimeOut = SockOpt (# const SOL_SOCKET ) (# const SO_RCVTIMEO )
258
259
#else
259
260
pattern RecvTimeOut = SockOpt (- 1 ) (- 1 )
260
261
#endif
261
- -- | SO_SNDTIMEO: this does not work at this moment.
262
+ -- | SO_SNDTIMEO: timeout in microseconds
262
263
pattern SendTimeOut :: SocketOption
263
264
#ifdef SO_SNDTIMEO
264
265
pattern SendTimeOut = SockOpt (# const SOL_SOCKET ) (# const SO_SNDTIMEO )
@@ -481,6 +482,8 @@ instance Storable StructLinger where
481
482
----------------------------------------------------------------
482
483
483
484
-- | Timeout in microseconds.
485
+ -- This will be converted into struct timeval on Unix and
486
+ -- DWORD (as milliseconds) on Windows.
484
487
newtype SocketTimeout = SocketTimeout Word32 deriving (Eq , Ord , Show )
485
488
486
489
#if defined(mingw32_HOST_OS)
You can’t perform that action at this time.
0 commit comments