Re: BSD #define (MSG_NOSIGNAL) vs. Apple #define (MSG_HAVEMORE)
- Subject: Re: BSD #define (MSG_NOSIGNAL) vs. Apple #define (MSG_HAVEMORE)
- From: Vincent Lubet <email@hidden>
- Date: Sat, 28 Dec 2002 09:34:47 -0800
Mac OS X does not support the flag MSG_NOSIGNAL but we have an equivalent.Starting with version 10.2 (Jaguar), Mac OS X has the socket option SO_NOSIGPIPE that prevents SIGPIPE from being raised when a write fails on a socket to which there is no reader; instead the write to the socket returns with the error EPIPE.VincentOn Thursday, December 19, 2002, at 02:23 PM, Jens Bauer wrote:
Hi all,
I'm porting some code, and ran across this problem.
In <sys/socket.h> I see the following:
...
#define MSG_EOF 0x100 /* data completes connection */
#ifdef __APPLE__
#define MSG_FLUSH 0x400 /* Start of 'hold' seq; dumpso_temp */
#define MSG_HOLD 0x800 /* Hold frag in so_temp */
#define MSG_SEND 0x1000 /* Send the packet in so_temp*/
#define MSG_HAVEMORE 0x2000 /* Data ready to be read */
#define MSG_RCVMORE 0x4000 /* Data remains in current pkt*/
#endif
#define MSG_COMPAT 0x8000 /* used in sendit() */
...
Now, the manpage for send says this:
#define MSG_OOB 0x1 /* process out-of-band data */
#define MSG_DONTROUTE 0x4 /* bypass routing, use directinterface */
#define MSG_DONTWAIT 0x40 /* don't block */
#define MSG_NOSIGNAL 0x2000 /* don't raise SIGPIPE */
MSG_OOB
Sends out-of-band data on sockets that support this notion (e.g.SOCK_STREAM); the underlying protocol must also support out-of-banddata.
MSG_DONTROUTE
Bypasses the usual routing table lookup and sends the packet directlyto the interface described by the destination address. This is usuallyused only by diagnostic or routing programs.
MSG_DONTWAIT
Enables non-blocking operation; if the operation would block, EAGAINis returned.
MSG_NOSIGNAL
Requests not to send SIGPIPE on errors on stream oriented sockets whenthe other end breaks the
connection. The EPIPE error is still returned.
MSG_NOSIGNAL clashes with Apple's MSG_HAVEMORE
(notice: MSG_DONTWAIT is 0x80 in my socket.h, but it seems it's 0x40in the Linux socket.h)
-I can't make up my own MSG_NOSIGNAL, so what should I do to thefollowing line...
return(-1 != ::send(m_Sock, s.c_str(), s.size(), MSG_NOSIGNAL));
Love,
Jens
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprogDo not post admin requests to the list. They will be ignored.
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。