打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
linux的MSG_NOSIGNAL和unix的SO_NOSIGPIPE

Re: BSD #define (MSG_NOSIGNAL) vs. Apple #define (MSG_HAVEMORE)


  • SubjectRe: 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.

Vincent

On 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/macnetworkprog
Do not post admin requests to the list. They will be ignored. 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
用户空间和内核空间通讯之Netlink
使用sockopt实现内核与用户之间通信
send和sendto的区别
linux 内核和用户空间通信之netlink使用方法
LWIP之SOCKET的实现
linux netlink通信机制
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服