Skip to content

Commit f536d35

Browse files
committed
improving docs and definitions as suggested by vdukhovni.
1 parent 7cc239a commit f536d35

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Network/Socket/Buffer.hsc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,20 @@ sendBufMsg s sa bufsizs cmsgs flags = do
238238
#endif
239239
return $ fromIntegral sz
240240

241-
-- | Receive data from the socket using recvmsg(2).
241+
-- | Receive data from the socket using recvmsg(2). The supplied
242+
-- buffers are filled in order, with subsequent buffers used only
243+
-- after all the preceding buffers are full. If the message is short
244+
-- enough some of the supplied buffers may remain unused.
242245
recvBufMsg :: SocketAddress sa
243246
=> Socket -- ^ Socket
244-
-> [(Ptr Word8,Int)] -- ^ A list of a pair of buffer and its size.
247+
-> [(Ptr Word8,Int)] -- ^ A list of (buffer, buffer-length) pairs.
245248
-- If the total length is not large enough,
246249
-- 'MSG_TRUNC' is returned
247250
-> Int -- ^ The buffer size for control messages.
248251
-- If the length is not large enough,
249252
-- 'MSG_CTRUNC' is returned
250253
-> MsgFlag -- ^ Message flags
251-
-> IO (sa,Int,[Cmsg],MsgFlag) -- ^ Source address, received data, control messages and message flags
254+
-> IO (sa,Int,[Cmsg],MsgFlag) -- ^ Source address, total bytes received, control messages and message flags
252255
recvBufMsg s bufsizs clen flags = do
253256
withNewSocketAddress $ \addrPtr addrSize ->
254257
allocaBytes clen $ \ctrlPtr ->

Network/Socket/Posix/Cmsg.hsc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,12 @@ pattern CmsgIdFd = CmsgId (#const SOL_SOCKET) (#const SCM_RIGHTS)
7070

7171
----------------------------------------------------------------
7272

73-
-- | Looking up control message. The following shows an example usage:
73+
-- | Locate a control message of the given type in a list of control
74+
-- messages. The following shows an example usage:
7475
--
7576
-- > (lookupCmsg CmsgIdIPv4TOS cmsgs >>= decodeCmsg) :: Maybe IPv4TOS
7677
lookupCmsg :: CmsgId -> [Cmsg] -> Maybe Cmsg
77-
lookupCmsg _ [] = Nothing
78-
lookupCmsg cid (cmsg:cmsgs)
79-
| cmsgId cmsg == cid = Just cmsg
80-
| otherwise = lookupCmsg cid cmsgs
78+
lookupCmsg cid cmsgs = find (\cmsg -> cmsgId cmsg == cid) cmsgs
8179

8280
-- | Filtering control message.
8381
filterCmsg :: CmsgId -> [Cmsg] -> [Cmsg]

0 commit comments

Comments
 (0)