setsocketopt getsocketopt比较全的参数说明
来源:互联网 发布:微软windows原版镜像 编辑:程序博客网 时间:2024/06/06 02:45
These socket options can be set by using setsockopt(2) and read withgetsockopt(2) with the socket level set toSOL_SOCKET for all sockets:
- SO_ACCEPTCONN
- Returns a value indicating whether or not this socket has been marked to accept connections withlisten(). The value 0 indicates that this is not a listening socket, the value 1 indicates that this is a listening socket. Can only be read withgetsockopt().
- SO_BSDCOMPAT
- Enable BSD bug-to-bug compatibility. This is used by the UDP protocol module in Linux 2.0 and 2.2. If enabled ICMP errors received for a UDP socket will not be passed to the user program. In later kernel versions, support for this option has been phased out: Linux 2.4 silently ignores it, and Linux 2.6 generates a kernel warning (printk()) if a program uses this option. Linux 2.0 also enabled BSD bug-to-bug compatibility options (random header changing, skipping of the broadcast flag) for raw sockets with this option, but that was removed in Linux 2.2.
- SO_BINDTODEVICE
- Bind this socket to a particular device like "eth0", as specified in the passed interface name. If the name is an empty string or the option length is zero, the socket device binding is removed. The passed option is a variable-length null terminated interface name string with the maximum size of IFNAMSIZ. If a socket is bound to an interface, only packets received from that particular interface are processed by the socket. Note that this only works for some socket types, particularlyAF_INET sockets. It is not supported for packet sockets (use normalbind(8) there).
- SO_BROADCAST
- Set or get the broadcast flag. When enabled, datagram sockets receive packets sent to a broadcast address and they are allowed to send packets to a broadcast address. This option has no effect on stream-oriented sockets.
- SO_DEBUG
- Enable socket debugging. Only allowed for processes with the CAP_NET_ADMIN capability or an effective user ID of 0.
- SO_ERROR
- Get and clear the pending socket error. Only valid as a getsockopt(). Expects an integer.
- SO_DONTROUTE
- Don't send via a gateway, only send to directly connected hosts. The same effect can be achieved by setting theMSG_DONTROUTE flag on a socket send(2) operation. Expects an integer boolean flag.
- SO_KEEPALIVE
- Enable sending of keep-alive messages on connection-oriented sockets. Expects an integer boolean flag.
- SO_LINGER
- Sets or gets the SO_LINGER option. The argument is a linger structure.
struct linger { int l_onoff; /* linger active */ int l_linger; /* how many seconds to linger for */};
- When enabled, a close(2) orshutdown(2) will not return until all queued messages for the socket have been successfully sent or the linger timeout has been reached. Otherwise, the call returns immediately and the closing is done in the background. When the socket is closed as part of exit(2), it always lingers in the background.
- SO_OOBINLINE
- If this option is enabled, out-of-band data is directly placed into the receive data stream. Otherwise out-of-band data is only passed when theMSG_OOB flag is set during receiving.
- SO_PASSCRED
- Enable or disable the receiving of the SCM_CREDENTIALS control message. For more information seeunix(7).
- SO_PEERCRED
- Return the credentials of the foreign process connected to this socket. This is only possible for connectedPF_UNIX stream sockets and PF_UNIX stream and datagram socket pairs created usingsocketpair(2); seeunix(7). The returned credentials are those that were in effect at the time of the call toconnect(2) orsocketpair(2). Argument is aucred structure. Only valid as a getsockopt().
- SO_PRIORITY
- Set the protocol-defined priority for all packets to be sent on this socket. Linux uses this value to order the networking queues: packets with a higher priority may be processed first depending on the selected device queueing discipline. Forip(7), this also sets the IP type-of-service (TOS) field for outgoing packets. Setting a priority outside the range 0 to 6 requires theCAP_NET_ADMIN capability.
- SO_RCVLOWAT and SO_SNDLOWAT
- Specify the minimum number of bytes in the buffer until the socket layer will pass the data to the protocol (SO_SNDLOWAT) or the user on receiving (SO_RCVLOWAT). These two values are initialised to 1.SO_SNDLOWAT is not changeable on Linux (setsockopt fails with the errorENOPROTOOPT). SO_RCVLOWAT is changeable only since Linux 2.4. Theselect(2) andpoll(2) system calls currently do not respect theSO_RCVLOWAT setting on Linux, and mark a socket readable when even a single byte of data is available. A subsequent read from the socket will block untilSO_RCVLOWAT bytes are available.
- SO_RCVTIMEO and SO_SNDTIMEO
- Specify the receiving or sending timeouts until reporting an error. The parameter is astruct timeval. If an input or output function blocks for this period of time, and data has been sent or received, the return value of that function will be the amount of data transferred; if no data has been transferred and the timeout has been reached then -1 is returned with errno set to EAGAIN or EWOULDBLOCK just as if the socket was specified to be nonblocking. If the timeout is set to zero (the default) then the operation will never timeout.
- SO_RCVBUF
- Sets or gets the maximum socket receive buffer in bytes. The kernel doubles this value (to allow space for bookkeeping overhead) when it is set usingsetsockopt(), and this doubled value is returned by getsockopt(). The default value is set by thermem_default sysctl and the maximum allowed value is set by the rmem_max sysctl. The minimum (doubled) value for this option is 256.
- SO_RCVBUFFORCE (since Linux 2.6.14)
- Using this socket option, a privileged (CAP_NET_ADMIN) process can perform the same task asSO_RCVBUF, but the rmem_max limit can be overridden.
- SO_REUSEADDR
- Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. ForPF_INET sockets this means that a socket may bind, except when there is an active listening socket bound to the address. When the listening socket is bound toINADDR_ANY with a specific port then it is not possible to bind to this port for any local address.
- SO_SNDBUF
- Sets or gets the maximum socket send buffer in bytes. The kernel doubles this value (to allow space for bookkeeping overhead) when it is set usingsetsockopt(), and this doubled value is returned by getsockopt(). The default value is set by thewmem_default sysctl and the maximum allowed value is set by the wmem_max sysctl. The minimum (doubled) value for this option is 2048.
- SO_SNDBUFFORCE (since Linux 2.6.14)
- Using this socket option, a privileged (CAP_NET_ADMIN) process can perform the same task asSO_SNDBUF, but the wmem_max limit can be overridden.
- SO_TIMESTAMP
- Enable or disable the receiving of the SO_TIMESTAMP control message. The timestamp control message is sent with levelSOL_SOCKET and the cmsg_data field is a struct timeval indicating the reception time of the last packet passed to the user in this call. Seecmsg(3) for details on control messages.
- SO_TYPE
- Gets the socket type as an integer (like SOCK_STREAM). Can only be read withgetsockopt().
参考文章:
http://linux.die.net/man/7/socket
- setsocketopt getsocketopt比较全的参数说明
- SetSocketopt()和getsocketopt() 参数说明
- Linux下getsocketopt 与 setsocketopt函数说明
- android:inputType参数类型说明,比较全
- 比较全的参数绑定方式
- setsocketopt。。。。
- setsocketopt
- fio使用指南(最全的参数说明)
- fio使用指南(最全的参数说明)
- 比较详细的ffmpeg参数功能 分类说明
- 一份比较详细的DOS命令说明 (有%1参数说明)
- sphinx 配置文件全解析 参数说明
- CreateEvent()的参数说明
- CreateEvent()的参数说明
- DEBUG的参数说明
- DEBUG的参数说明
- createStatement()的参数说明
- DEBUG的参数说明
- rails server Could not find gem 'sqlite3-ruby (>= 0)'
- 洁癖的程序员
- oracle 表空间 相关
- 从Hadoop框架与MapReduce模式中谈海量数据处理(含淘宝技术架构)
- ARM-Linux移植攻略--yaffs2 Partially written block xxx detected 问题解决
- setsocketopt getsocketopt比较全的参数说明
- http://blog.csdn.net/xys289187120/article/category/837416
- jQuery技巧大放送
- Wcf通讯基础框架方案(一)——基本结构
- 基于 Android NDK 的学习之旅-----数据传输二(引用数据类型)(附源码)
- 老罗的Android之旅——Android应用程序的Activity启动过程简要介绍和学习计划
- Ogre3d:OGRE中的Animation动画基础
- Window 消息——消息的格式
- [转]#pragma 预处理指令详解