Skip to content

Commit

Permalink
updating doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed May 23, 2023
1 parent 94436bb commit 353d8ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Network/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ module Network.Socket
,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo
,RecvIPv6HopLimit,RecvIPv6TClass,RecvIPv6PktInfo)
, StructLinger (..)
, SocketTimeout (..)
, isSupportedSocketOption
, whenSupported
, getSocketOption
Expand Down
5 changes: 5 additions & 0 deletions Network/Socket/ByteString/IO.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ sendManyTo s cs addr = do
--
-- For TCP sockets, a zero length return value means the peer has
-- closed its half side of the connection.
--
-- Currently, the 'recv' family is blocked on Windows because a proper
-- IO manager is not implemented. To use with 'System.Timeout.timeout'
-- on Windows, use 'Network.Socket.setSocketOption' with
-- 'Network.Socket.RecvTimeOut' as well.
recv :: Socket -- ^ Connected socket
-> Int -- ^ Maximum number of bytes to receive
-> IO ByteString -- ^ Data received
Expand Down
7 changes: 5 additions & 2 deletions Network/Socket/Options.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Network.Socket.Options (
, getSockOpt
, setSockOpt
, StructLinger (..)
, SocketTimeout (..)
) where

import qualified Text.Read as P
Expand Down Expand Up @@ -251,14 +252,14 @@ pattern SendLowWater = SockOpt (#const SOL_SOCKET) (#const SO_SNDLOWAT)
#else
pattern SendLowWater = SockOpt (-1) (-1)
#endif
-- | SO_RCVTIMEO: this does not work at this moment.
-- | SO_RCVTIMEO: timeout in microseconds
pattern RecvTimeOut :: SocketOption
#ifdef SO_RCVTIMEO
pattern RecvTimeOut = SockOpt (#const SOL_SOCKET) (#const SO_RCVTIMEO)
#else
pattern RecvTimeOut = SockOpt (-1) (-1)
#endif
-- | SO_SNDTIMEO: this does not work at this moment.
-- | SO_SNDTIMEO: timeout in microseconds
pattern SendTimeOut :: SocketOption
#ifdef SO_SNDTIMEO
pattern SendTimeOut = SockOpt (#const SOL_SOCKET) (#const SO_SNDTIMEO)
Expand Down Expand Up @@ -481,6 +482,8 @@ instance Storable StructLinger where
----------------------------------------------------------------

-- | Timeout in microseconds.
-- This will be converted into struct timeval on Unix and
-- DWORD (as milliseconds) on Windows.
newtype SocketTimeout = SocketTimeout Word32 deriving (Eq, Ord, Show)

#if defined(mingw32_HOST_OS)
Expand Down

0 comments on commit 353d8ef

Please sign in to comment.