asymmetry with MSG_DONTWAIT in sendmsg() and recvmsg()
Subsystems (2)
I have a SOCK_STREAM PF_UNIX socket with no special options enabled using fcntl().
The default with sendmsg() and recvmsg() is to block.
With sndmsg(), I can use the MSG_DONTWAIT flag to enable non-blocking operation for that one call.
How do I do the equivalent for recvmsg()?
Thanks,
Chris
Quoted 9 lines
I have a
SOCK_STREAMPF_UNIXsocket with no special options enabled usingfcntl().The default with
sendmsg()andrecvmsg()is to block.With
sndmsg(), I can use theMSG_DONTWAITflag to enable non-blocking operation for that one call.How do I do the equivalent for
recvmsg()?
MSG_DONTWAIT should also work with recvmsg().
Cheers
Signature · 5 lines
Michael Kerrisk [email protected] "Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen! Jetzt aktivieren unter http://www.gmx.net/info
Quoted 1 line · Michael T Kerrisk
MSG_DONTWAITshould also work withrecvmsg().
Hmm... Just tried it with a DGRAM socket, and it seems to work. Any ideas why its not in the man pages?
Chris
Quoted 6 lines · Chris Friesen
Quoted 1 line · Michael T Kerrisk
MSG_DONTWAITshould also work withrecvmsg().Hmm... Just tried it with a DGRAM socket, and it seems to work. Any ideas why its not in the man pages?
Nobody ever added it? Just send a patch to [email protected]
-Andi
Quoted 10 lines · Andi Kleen
Quoted 5 lines · Chris Friesen
Quoted 1 line · Michael T Kerrisk
MSG_DONTWAITshould also work withrecvmsg().Hmm... Just tried it with a DGRAM socket, and it seems to work. Any
ideas
Quoted 1 line
why its not in the man pages?
Nobody ever added it? Just send a patch to [email protected]
Sending patch as suggested. Fundamentally, the delta is as follows, I've included an attachment with what I hope are the proper formatting codes (copied from send(2)).
recv2.man 2004-07-08 15:47:29.000000000 -0400 renamed from recv.man 2004-07-08 15:43:17.000000000 -0400 +5 -0
@@ -67,6 +67,11 @@ disconnect occurs, or the next data to be received is of a dif- ferent type than that returned. + MSG_DONTWAIT + Enables non-blocking operation; if the operation would block, + EAGAIN is returned (this can also be enabled using the O_NON- + BLOCK with the F_SETFL fcntl(2)). + MSG_NOSIGNAL This flag turns off raising of SIGPIPE on stream sockets when the other end disappears.
Note also that there is a mention of MSG_DONTWAIT in the msg_flags field in the msghdr. It gives the impression that one can *set* that field to cause the non-blocking behaviour. My understanding is that the msg_flags field is a return value only. Perhaps that portion should be reworded as well.
Chris
recv2.man renamed from recv.man +5 -0
@@ -67,6 +67,11 @@ disconnect occurs, or the next data to be received is of a dif- ferent type than that returned. + MMSSGG__DDOONNTTWWAAIITT + Enables non-blocking operation; if the operation would block, + EEAAGGAAIINN is returned (this can also be enabled using the OO__NNOONN-- + BBLLOOCCKK with the FF__SSEETTFFLL ffccnnttll(2)). + MMSSGG__NNOOSSIIGGNNAALL This flag turns off raising of SSIIGGPPIIPPEE on stream sockets when the other end disappears.
Quoted 28 lines · Chris Friesen
Quoted 3 lines
Quoted 1 line
why its not in the man pages?
Nobody ever added it? Just send a patch to [email protected]
Sending patch as suggested. Fundamentally, the delta is as follows, I've included an attachment with what I hope are the proper formatting codes (copied from send(2)).
recv2.man 2004-07-08 15:47:29.000000000 -0400 renamed from recv.man 2004-07-08 15:43:17.000000000 -0400 +3
-0@@ -67,6 +67,11 @@ disconnect occurs, or the next data to be received is of a dif- ferent type than that returned. + MSG_DONTWAIT + Enables non-blocking operation; if the operation would block, + EAGAIN is returned (this can also be enabled using theO_NON-
recv2.man 2004-07-08 15:47:29.000000000 -0400 renamed from recv.man 2004-07-08 15:43:17.000000000 -0400 +2
-0+ BLOCK with the F_SETFL fcntl(2)). + MSG_NOSIGNAL This flag turns off raising of SIGPIPE on stream sockets when the other end disappears.
Quoted 6 lines
Note also that there is a mention of
MSG_DONTWAITin themsg_flagsfield in the msghdr. It gives the impression that one can *set* that field to cause the non-blocking behaviour. My understanding is that themsg_flagsfield is a return value only. Perhaps that portion should be reworded as well.Chris
Can you find the man-pages-1.67 package and construct a concrete patch?
(Don't know precisely what you want to do. The above gives a filename recv.man, which would be recv.2 in my sources. But there is no MSG_NOSIGNAL in recv.2, only in send.2. The fragment of text that you give occurs already in recv.2.)
Andries
Quoted 6 lines · Andries Brouwer
Can you find the man-pages-1.67 package and construct a concrete patch?
(Don't know precisely what you want to do. The above gives a filename recv.man, which would be recv.2 in my sources. But there is no
MSG_NOSIGNALin recv.2, only in send.2. The fragment of text that you give occurs already in recv.2.)
Sorry, the filenames have no meaning since I wasn't working from the package, but from the output of the "man" command.
Working from the webpage at:
http://homepages.cwi.nl/~aeb/linux/man2html/man2/recv.2.html
There is mention of MSG_DONTWAIT when discussing the "msg_flags" field in "struct msghdr". It contains exactly the text proposed. However, the msg_flags field is set on *return* of the call. Every other flag discussed there "indicates" something. The blurb for MSG_DONTWAIT says that it "enables" a behaviour, which doesn't make sense for a field set on call return.
There is no mention of MSG_DONTWAIT when discussing the "flags" parameter of the recv/recvfrom/recvmsg call.
Generally, I want to move the current blob from the "msg_flags" area to the "flags" area, and then add a different discussion for "msg_flags" if appropriate (I'm not sure about that part).
Do you still want me to generate an actual patch against man-pages-1.67, or is that description enough?
Chris
Quoted 11 lines · Chris Friesen
Quoted 6 lines · Andries Brouwer
Can you find the man-pages-1.67 package and construct a concrete patch?
(Don't know precisely what you want to do. The above gives a filename recv.man, which would be recv.2 in my sources. But there is no
MSG_NOSIGNALin recv.2, only in send.2. The fragment of text that you give occurs already in recv.2.)Working from the webpage at:
http://homepages.cwi.nl/~aeb/linux/man2html/man2/recv.2.html
Ah, that is how I am punished for neglecting to update these html pages :-) Will update them.
I was confused by your MSG_NOSIGNAL, but indeed, that is still on that page, it was removed later.
Have moved the MSG_DONTWAIT part to after the MSG_WAITALL description. [Will still check whether that is really appropriate.]
Thanks!
Andries
Quoted 6 lines · Chris Friesen
Quoted 1 line · Michael T Kerrisk
MSG_DONTWAITshould also work withrecvmsg().Hmm... Just tried it with a DGRAM socket, and it seems to work. Any ideas why its not in the man pages?
Think you are on an older version of the man pages. It's been there for a while.
thanks,
Nivedita
Quoted 11 lines · Nivedita Singhvi
Quoted 7 lines · Chris Friesen
Quoted 1 line · Michael T Kerrisk
MSG_DONTWAITshould also work withrecvmsg().Hmm... Just tried it with a DGRAM socket, and it seems to work. Any ideas why its not in the man pages?
Think you are on an older version of the man pages. It's been there for a while.
It's mentioned in the "msg_flags" section, which is set on call *return*. It's not mentioned in the "flags" section.
Perhaps its just in the wrong part of the man page...
Chris