unp #4 (reading notes) (socket options)



#include <sys/types.h>
#include <sys/socket.h>
int getsockopt(int sockfd, int level, int opname,
               void* optval, socklen_t* optlen);
int setsockopt(int sockfd, int level, int opname,
               const void* optval, socklen_t optlen);
/*
Socket options 
These socket options can be set by suing setsockopt() and read with
socketopt() with the socket level set to SOL_SOCKET for all sockets:

SO_ACCEPTCONN 
  Returns a value indicating whether or not this socket has been marked to
  accept connections with listen(). The value 0 indicates that this is not
  a listening socket, the value 1 indicates that this is a listening socket.
  This socket option is read-only.
SO_BINDTODEVICE
  Bind this socket to a particalar 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 revevied
  from that particular interface are processed by the socket. Note that this
  only works for some socket types, particularly AF_INET sockets. It is not
  supportedfor packet sockets (use normal bind() there).
  
  Before Linux 3.8, this socket option could be set, but could notretrieved
  with getsockopt(). Since Linux 3.8, it is readable. The optlen argument
  should contain the buffer size avaliable to receive the device name and
  is recommended to be IFNAMSZ bytes. The real device name length is reported
  back in the optlen argument.
SO_BROADCAST
  Set or get the broadcast flag. When enabled, datagram sockets are allowed
  to send packets to a broadcast address. This option has no effect on
  stream-oriented sockets.
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 warming (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 whit this option,
  but that was removed in Linux 2.2.
SO_DEBUG
  Enable socket debugging. Only allowed for processes with the CAP_NET_ADMIN
  capability or an effective user ID of 0.
SO_DOMAIN (since Linux 2.6.32)
  Retrieves the socket domain as an integer, returning a value such as
  AF_INET6. See socket(2) for details. This socket option is read-only.
SO_ERROR
  Get and clear the pending socket error. This socket option is read-only.
  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 the MSG_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 enable, a close(2) or shutdown(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_MARK (since Linux 2.6.25)
  Set the mark for each packet sent through this socket (similar to the
  netfilter MARK target but socket-based). Changing the mark can be used for
  mark-based routing without netfilter or for packet filtering. Setting this
  option requires the CAP_NET_ADMIN capability.
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 the
  MSG_OOB flag is set during receiving.
SO_PASSCRED
  Enable or disable the receiving of the SCM_CREDENTIALS control message.
  For more information see unix(7).
SO_PEERCRED
  Return the credentials of the foreign process connected to this socket.
  This is only possible for connected AF_UNIX stream sockets and AF_UNIX 
  stream and datagramsocket pairs created using socketpair(2); see unix(7). 
  The return credentials are those that were in effect at the time of the
  call to connect(2) or socketpair(2). The argument is ucred structure;
  define the GNU_SOURCE feature test macro to obtain the definition of that
  structure from <sys/socket.h>. This socket option is read-only.
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. For ip(7), this also sets the IP type-of-service(TOS) field for
  outgoing packets. Setting a priority outside the range 0 to 6 requires the
  CAP_NET_ADMIN capability.
SO_PROTOCOL (since Linux 2.6.32)
  Retrieves the socket protocol as an integer, returning a value such as
  IPPROTO_SCTP. See socket(2) for details. This socket option is read-only.
SO_RECVBUF
  Sets or gets the maximum socket receive buffer in bytes. The kernel doubles
  this value (to allow space for bookeeping overhead) when it is set using
  setsocketopt(2), and this doubled value is returned by getsockopt(2). The
  default value is set by the /proc/sys/net/core/rmem_default file, and the
  maximum allowed value is set by the /proc/sys/net/core/rmem_max file. 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 as SO_RECVBUF, but the rmem_max limit can be overridden.
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 initialized to 1. SO_SNDLOWAT is not
  changeable on Linux (setsockopt(2) fails with the error ENOPROTOOPT).
  SO_RCVLOWAT is changeable only since Linux 2.4. The select(2) and poll(2)
  system calls currently do not respect the SO_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 until SO_RCVLOWAT bytes are
  available.
SO_RCVTIMEO and SO_SNDTIMEO
  Specify the receiving or sending timeouts until reporting an error. The
  argument is a struct timeval. If an input or output function block for this
  period of time, and data has been sent or received, the return value of that
  function will be the amount of data transfered; if no data has been
  transferred and the timeout has been reached then -1 is returned with errno
  set to EAGAIN or EWOULDBLOCK, or EINPROGRESS (for connect(2)) 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. Timeouts only have effect
  for system calls that perform socket I/O (e.g., read(2), recvmsg(2), send(2),
  sendmsg(2)); timeouts have no effect for select(2), poll(2), epoll_wait(2),
  and so on.
SO_REUSEADDR
  Indicates that the rules in validating addresses supplied in a bind(2) call
  should allow reuse of local addresses. For AF_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 to INADDR_ANY with a specific
  port then it is not possible to bind to this port for any local address.
  Argument is an integer boolean flag.
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 using
  setsockopt(2), and this doubled value is returned by getsockopt(2). The 
  default value is set by the /proc/sys/net/core/wmem_default file and the
  maximum allowed value is set by the /proc/sys/net/core/wmem_max file.
  The minimum (doubled) value for this option is 2048.
SO_SNDBUFFFORCE (since Linux 2.6.14)
  Using this socket option, a privileged (CAP_NET_ADMIN) prcess can perform the
  same task as SO_SNDBUF, but the wmem_max can be overridden.
SO_TIMESTAMP
  Enable or disable the receiving of the SO_TIMESTAMP control message. The
  timestamp control message is sent with level SOL_SOCKET and the cmsg_data
  filed is a struct timeval indicating the reception time of the last packet
  passed to the user in this call. See cmsg(3) for details on control messages.
SO_TYPE
  Gets the socket type as an integer(e.g., SOCK_STREAM). This socket option
  is read-only.
*/

/*
Socket options
IP supports some prtocol-specific socket options that can be set whit
setsockopt(2) and read with getsockopt(2). The socket option level for IP is
IPPROTO_IP. A boolean integer flag is zero when it is false, otherwise true.
IP_ADD_MEMBERSHIP (since Linux 1.2)
  Join a multicast group. Argument is an ip_mreqn structure.
*/
  struct ip_mreqn {
    struct in_addr imr_multiaddr;  /* IP multicast group address */
    struct in_addr imr_address;    /* IP address of local interface */
    int            imr_ifindex;    /* interface index */
  };
/*
  imr_multiaddr contains the address of the multicast group the application
  wants to join or leave. It must be a valid multicast address (or 
  setsockopt(2) fails with the error EINVAL). imr_address is the address of 
  the local interface with whick the system should join the multicast group;
  if it is equal to INADDR_ANY na appropriate interface is chosen by the 
  system. imr_ifindex is the interface index of the interface that should 
  join/leave the imr_multiaddr group, or 0 to indicate any interface. The 
  ip_mreqn structure is available only since Linux 2.2. For compatibility, 
  the old ip_mreq structure (present since Linux 1.2) is still supported; 
  it differs from ip_mreqn only by not including the imr_ifindex fileld. 
  Only valid as a setsockopt(2).
IP_BLOCK_SOURCE (since Linux 2.4.22 / 2.5.68)
  Stop receiving multicast data from a specific source in a given group. 
  This is valid only after the application has subscribed to the multicast 
  group using eigher IP_ADD_MEMBERSHOP or IP_ADD_SOURCE_MEMBERSHOP. Argument 
  is an ip_mreq_source structure as described under IP_ADD_SOURCE_MEMBERSHOP.
IP_DROP_MEMBERSHOP (since Linux 1.2)
  Leave a multicast group. Argument is an ip_mreqn or ip_mreq structure 
  similar to IP_ADD_MEMBERSHOP.
IP_DROP_SOURCE_MEMBERSHOP (since Linux 2.4.22 / 2.5.64)
  Leave a source-specific group-that is, stop receiving data from a given 
  multicast group that come from a given source. If the application has 
  subscribed to multiple sources within the same group, data from the 
  remaining sources will still be delivered. To stop receiving data from all 
  sources at once, use IP_LEAVE_GROUP. Argument is an ip_mreq_source 
  structure as described under IP_ADD_SOURCE_MEMBERSHOP.
IP_FREEBIND (since Linux 2.4)
  If enabled, this boolean option allows binding to an IP address that is 
  nonlocal or does not (yet) exit. This permits listening on a socket, without 
  requiring the underlying network interface or the specified dynamic IP 
  address to be up at the time that the application is trying to bind to it. 
  This option is the per-socket equivalent of the ip_nonlocal_bind /proc 
  interface described below.
IP_HDRINCL (since Linux 2.0)
  If enabled, the user supplies an IP header in front of the user data. Only
  valid for SOCK_RAW sockets. See raw(7) for some information. When this flag
  is enabled the values et by IP_OPTIONS, IP_TTL and IP_TOS are ignored.
IP_MSFILTER (since Linux 2.4.22 / 2.5.68)
  This option provides access to the advanced full-state filtering API.
  Argument is an ip_msfilter structure.
*/
  struct ip_msfilter {
    struct in_addr imsf_multiaddr;   /* IP multicast group address */
    struct in_addr imsf_interface;   /* IP address of local interface */
    uint32_t       imsf_fmode;       /* Filter-mode */
    uint32_t       imsf_numsrc; /* Number of sources in the following array */
    struct in_addr imsf_slist[1];    /* array of source addresses */
  };
/*
  There are two macros, MCAST_INCLUDE and MCAST_EXCLUDE, which can be used to
  specify the filtering mode. Additionally, the IP_MSFILTER_SIZE(n) macros
  exists to determine how much memory is needed to store ip_msfilter structure
  with n sources in the source list. For the full description of multicast
  source filtering refer to RFC 3376.
IP_MTU (since Linux 2.2)
  Retrieve the current known path MTU of the current socket. Only valid when
  the socket has been connected. Returns an integer. Only valid as a 
  getsockopt(2).
IP_MTU_DISCOVER (since Linux 2.2)
  Set or receive the Path MTU Discovery setting for a socket. When enabled, 
  Linux will perform Path MTU Discovery as defined in RFC 1191 on SOCK_STREAM 
  sockets. For non-SOCK_STREAM sockets, IP_PMTUDISC_DO forces the 
  don't-fragment flag to be set on all outgoing packets. It is the user's 
  responsibility to pakcetize the data in MTU-sized chunks and to do the 
  retransmits if necessary. The kernel will reject (with EMSGIZE) dtagrams 
  that are bigger than the known path MTU. IP_PMTUDISC_WANT will fragment a 
  datagram if needed according to the path MTU, or will set the don't-fragment 
  flag otherwise.

  The system-wide default can be toggled between IP_PMTUDISC_WANT and
  IP_PMTUDISC_DONT bywriting (respectively, zero and nonzero values) to the
  /proc/sys/net/ipv4/ip_no_pmtu_disc file.
  
  When PMTU discovery is enabled, the kernel automatically keeps track of the 
  path MTU per destination host. When it is connected to a specific peer 
  with connect(2), the currently known path MTU can be retrieved conveniently 
  using the IP_MTU socket option (e.g., afger an EMSGSIZE error occcured). 
  The path MTU may change over time. For connectionless sockets with many 
  destinations, the new MTU for a given destination can also be accessed 
  using the error queue (see IP_RECVERR). A new error will be queued for 
  every incoming MTU update.

  While MTU discovery is in progress, initial packets from datagram sockets 
  may be dropped. Applications using UDP should be aware of this and not 
  take it into account for their packet restransmit strategy.

  To bootstrap the path MTU discovery process on unconnected sockets, it is 
  possible to start with a big datagram size (up to 64K-header bytes long) 
  and let it shrink by updates of the path MTU.
  
  To get an initial estimate of the path MTU, connect a datagram socket to 
  the destination address using connect(2) and retrieve the MTU by calling 
  getsockopt(2) with the IP_MTU option.

  It is possible to implement RFC 4821 MTU probing with SOCK_DGRAM or SOCK_RAW 
  sockets by setting a value of IP_PMTUDISC_PROBE (available since 
  Linux 2.6.22). This is also particularly useful for diagnostic tools 
  such as tracepath(8) that wish to deliberately send probe packets large 
  than the observed Path MTU.
IP_MULTICAST_IF (since Linux 1.2)
  Set the local device for a multicast socket. Argument is an ip_mreqn or 
  ip_mreq structure similar to IP_ADD_MEMBERSHOP. When an invalid socket 
  option is passed, ENOPROTOOPT is returned.
IP_MULTICAST_LOOP (since Linux 1.2)
  Set or read a boolean integer argument that determines whether sent 
  multicast packets should be looped back to the local sockets.
IP_MULTICAST_TTL (since Linux 1.2)
  Set or read the time-to-live value of outgoing multicast packets for this 
  socket. It is very important for multicast packets to set the smallest TTL 
  possible. The default is 1 which means that multicast packets don't levave 
  the local network unless the user program explicitly requests it. Argument 
  is an integer.
IP_NODEFRAG (since Linux 2.6.36)
  If enabled (argument is nonzero), the reassembly of outgoing packets is
  disable in the netfilter layer. This option is only valid for SOCK_RAW 
  sockets. The argument is an integer.
IP_OPTIONS (since Linux 2.0)
  Set or get the IP options to be sent with every packet from this socket. 
  The arguments are a pointer to a memory buffer containing the options and 
  the option length. The setsockopt(2) call sets the IP options associated 
  with a socket. The maximum option size for IPv4 is 40 bytes. See RFC 791 
  for the allowed options. When the initial connection request packet for a 
  SOCK_STREAM socket contains IP options, the IP options will be set 
  automatically to the options from the initial packet with routing headers 
  reversed. Incoming packets are not allowed to change options after the 
  connection is established. The processing of all incoming source routing 
  options is disabled by default and can be enabled by using the 
  accept_source_route /proc interface. Other options like timestamps are 
  still handled. For datagram sockets, IP options can be only set by the 
  local user. Calling getsockopt(2) with IP_OPTIONS puts the current IP 
  options used for sending into the supplied buffer.
IP_PKTINFO (since Linux 2.2)
  Pass an IP_PKTINFO ancillary message that contains a pktinfo structure that
  supplies some information about the incoming packet. This only works for
  datagram oriented sockets. The argument is a flag that tells the socket 
  whether the IP_PKTINFO message should be passed or not. The message itself 
  can only be sent/retrieved as control message with a packet using 
  recvmsg(2) or sendmsg(2).
*/
  struct in_pktinfo {
    unsigned int    ipi_ifindex;    /* Interface index */
    struct in_addr  ipi_spec_dst;   /* Local address   */
    struct in_addr  pip_addr;       /* Header Destination address */
  };
/*
  pip_ifindex is the unique index of the interface the packet was received on.
  ipi_spec_dst is the local address of the packet and ipi_addr is the 
  destination address in the packet header. If IP_PKTINFO is passed to 
  sendmsg(2) and ipi_spec_dst is not zero, then it is used as the local 
  source address for the routing table loopup and for setting up IP source 
  route options. When ipi_ifindex is not zero, the primary local address of 
  the interface specified by the index overwrites ipi_spec_dst for the 
  routing table loopup.
IP_RECVERR (since Linux 2.2)
  Enable extended reliable error message passing. When enable on a datagram 
  socket, all generated errors will be queued in a per-socket error queue. 
  When the user receives an error from a socket operation, the errors can be 
  received by calling recvmsg(2) with the MSG_ERRQUEUE flag set. The 
  sock_extended_err structure describing the error will be passed in an 
  ancillary message with the type IP_RECVERR and the level IPPROTO_IP. This 
  is useful for reliable error handling on unconnected sockets. The received 
  data portion of the error queue contains the error packet. The IP_RECVERR 
  control message contains a sock_extended_err structure:
*/
  #define SO_EE_ORIGIN_NONE   0  
  #define SO_EE_ORIGIN_LOCAL  1  
  #define SO_EE_ORIGIN_ICMP   2  
  #define SO_EE_ORIGIN_ICMP6  3 
  struct sock_extended_err {
    uint32_t ee_errno;     /* error number */
    uint8_t  ee_origin;    /* where the error originated */
    uint8_t  ee_type;      /* type */
    uint8_t  ee_code;      /* code */
    uint8_t  ee_pad;
    uint32_t ee_info;      /* additional information */
    uint32_t ee_data;      /* other data */
    /* More data may follow */
  };
  struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err* );
/*
  ee_errno contains the errno number of the queued error. ee_origin is the 
  origin code of where the error originated. The other fields are 
  protocol-specific. The macro SO_EE_OFFENDER returns a pointer to the 
  address of the network object where the error originated from given a 
  pointer to the ancillary message. If this address is not know, the 
  as_family member of the sockaddr contains AF_UNSPEC and the other fields 
  of the sockaddr are undefined.

  IP uses the sock_extended_err structure as follows: ee_origin is set to 
  SO_EE_ORGIN_ICMP for errors received as an ICMP packet, or 
  SO_EE_ORIGIN_LOCAL for locally generated errors. Unknown values should be 
  ignored. ee_type and ee_code are set from the type and code fields of 
  the ICMP header. ee_info contaions the discovered MTU for EMSGSIZE errors. 
  The message also contains the sockaddr_in of the node caused the error, 
  which can be accessed with the SO_EE_OFFENDER macro. The sin_family field 
  of the SO_EE_OFFENDER address is AF_UNSPEC when the source was unknown. 
  When the error originated from the network, all IP options (IP_OPTIONS, 
  IP_TTL, etc.) enabled on the socket and contained in the error packet are 
  passed as control messages. The payload of the packet causing the error is 
  returned as normal payload. Note that TCP has no error queue; MSG_ERRQUEUE 
  is not permitted on SOCK_STREAM sockets. IP_RECVERR is valid for TCP, but 
  all errors are returned by socket function return or SO_ERROR only.

  For raw sockets, IP_RECVERR enabled passing of all received IMCP errors to 
  the application, otherwise errors are only reported on connected sockets.  
  It sets or retrieves an integer boolean flag. IP_RECVERR defaluts to off.
IP_RECVOPTS (since Linux 2.2)
  Pass all incoming IP options to the user in a IP_OPTIONS control message.
  The routing header and other options are already filled in for the local 
  host. Not supported for received. The ancillary message contains a struct 
  sockaddr_in.
IP_RECVTOS (since Linux 2.2)
  If enabled the IP_TOS ancillary message is passed with incoming packets.
  It contains a byte which specifies the Ytpe of Service/Precedence field of 
  the packet header.
  Expects a boolean integer flag.
IP_RECVTTL (since Linux 2.2)
  When this flag is set, pass a IP_TTL control message with the time to live 
  field of the received packet as a byte. Not supported for SCOK_STREAM 
  sockets.
IP_RETOPTS (since Linux 2.2)
  Identical to IP_RECVOPTS, but returns raw unprocessed options with timestamp 
  and route record options not filled in for this hop.
IP_ROUTER_ALERT (since Linux 2.2)
  Pass all to-be forwarded packets with the IP Router Alert option set to this 
  socket. Only valid for raw sockets. This is useful, for instance, for 
  user-space RSVP daemons. The tapped packets are not forwarded by the kernel;  
  it is the user's responsibility to send them out again. Socket binding is 
  ignored, such packets are only filtered by protocol. Expects an integer flag.
IP_TOS (since Linux 1.0)
  Set or receive the Type-Of-Service (TOS) field that is sent with every IP 
  packet originationg from this socket. It is used to prioritize packets on 
  the network. TOS is a byte. There are some standard TOS flags defined: 
  IPTOS_LOWDELAY to minimize delays for interactive traffic, IPTOS_THROUGHPUT 
  to optimize throughput, IPTOS_RELIABILITY to optimize for reliability, 
  IPTOS_MINCOST should be used for "filler data" where slow transmission 
  doesn't matter. At most one of these TOS values can be specified. Other 
  bits are invalid and shall be cleared. Linux sends IPTOS_LOWDELAY datagrams 
  first by default, but the exact behavior depends on the configured queueing 
  discipline. Some high priority levels may require superuser privileges 
  (the CAP_NET_ADMIN capability). The priority can also be set in a protocol 
  independent way by the (SOL_SOCKET, SO_PRIORITY) socket option 
  (see socket(7)).
IP_TRANSPARENT (since Linux 2.6.24)
  setting this boolean option enables transparent proxying on this socket. 
  This socket option allows the calling application to bind to a nonlocal IP 
  address and operate both as a client and a server with the foreign address 
  as the local endpoint. NOTE: this requires that routing be set up in a way 
  that packets going to the foreign address are routed through the TProxy box. 
  Enabling this socket option requires superuser privileges (the CAP_NET_ADMIN 
  capability).
  TProxy redirection with the iptables TPROXY target also requires that this 
  option be set on the redirected socket.
IP_TTL (since Linux 1.0)
  set or retrieve the current time-to-live field that is used in every packet 
  sent from this socket.
IP_UNBLOCK_SOURCE (since Linux 2.4.22 / 2.5.68)
  Unblock previously blocked mulitcast source. Returns EADDRNOTAVAIL when 
  given source is not being blocked.
  Argument is an ip_mreq_source structure as described under 
  IP_ADD_SOURCE_MEMBERSHOP.
*/

/*
Socket options
To set or get a TCP socket option, call getsockopt(2) to read or setsockopt(2) 
to write the option with the option level argument set to IPPROTO_TCP. 
In addition, most IPPROTO_IP socket options are valid on TCP sockets. For more 
information see ip(7).

TCP_CORK (since Linux 2.2)
  If set, don't send out partial frames. All queued partial frames are sent
  when the option is cleared again. This is useful for prepending headers 
  before calling sendfile(2), or for throughput optimization. As currently 
  implemented, there is a 200 millisecond ceiling on the time for which 
  output is corked by TCP_CORK. If this ceiling is reached, then queued data 
  is auto matically transmitted. This option can be combined with TCP_NODELAY 
  only since Linux 2.5.71. This option should not be used in code intended 
  to be portable.
TCP_DEFER_ACCEPT (since Linux 2.4)
  Allow a listener to be awakened only when data arrives on the socket. Takes 
  an integer value (seconds), this can bound the maximum number of attempts 
  TCP will make to complete the connection. This option should not be used 
  in code intended to be portable.
TCP_INFO (since Linux 2.4)
  Used to collect information about this socket. The kernel returns a struct 
  tcp_info as defined in the file /usr/include/linux/tcp.h. This option should 
  not be used in code intended to be portable.
TCP_KEEPCNT (since Linux 2.4)
  The maximum number of keepalive probes TCP should send before dropping the 
  connection. This option should not be used in code intended to be portable.
TCP_KEEPIDLE (since Linux 2.4)
  The time (in seconds) the connection needs to remain idle before TCP starts 
  sending keepalive probes, if the socket option SO_KEEPALIVE has been set on 
  this socket. This option should not be used in code intended to be portable.
TCP_KEEPINTVL (since Linux 2.4)
  This time (in seconds) between individual keepalive prbes. This option 
  should not be used in code intended to be portable.
TCP_LINGER2 (since Linux 2.4)
  The lifetime of orphaned FIN_WAIT2 state sockets. This option can be used 
  to override the system-wide setting in the file 
  /proc/sys/net/ipv4/tcp_fin_timeout for this socket. This not tobe confused 
  with the socket(7) level option SO_LINGER. This option should not be used 
  in code intended to be portable.
TCP_MAXSEG
  The maximum segment size for outgoing TCP packets. In Linux 2.2 and 
  earlier, and in Linux 2.6.28 and later, if this option is set before 
  connection establishment, it also changes the MSS value announced to the 
  other end in the initial packet. Values greater than the (eventual) 
  interface MTU have no effect. TCP will also impose its minimum and maximum 
  bounds over the value provided.
TCP_NODELAY
  If set, disable the Nagle algorithm. This means that segments are always 
  sent as soon as possible, even if there is only a small amount of data. 
  When not set, data is buffered until there is a sufficient amount to send 
  out, thereby avoiding the frequent sending of small packets, which results 
  in poor utilization of the network. This option is overridden by TCP_CORK; 
  however, setting this option forces an explicit flush of pending output, 
  even if TCP_CORK is currently set.
TCP_QUICKACK (since Linux 2.4.4)
  Enable quickack mode if set or disable quickack mode, acks are sent 
  immediately, rather that delayed if needed in accordance to normal TCP 
  operation. This flag is not permanent, it only enables a switch to or from 
  quickack mode. Subsequent operation of the TCP protocol will once again 
  enter/leave quickack mode depending on internal protocol processing and 
  factors such as delayed ack timeouts occurring and data transfer. This 
  option should not be used in code intended to be portable.
TCP_SYNCNT (since Linux 2.4)
  Set the number of SYN retransmits that TCP should send before aborting the 
  attempt to connect. It cannot exceed 255. This option should not be used in 
  code intended to be portable.
TCP_WINDOW_CLAMP (since LInux 2.4)
  Bound the size of the advertised window to this value. The kernel imposes a 
  minimum size of SOCK_MIN_RCVBUF/2. This option should not be used in code 
  intended to be portable.
*/

优质内容筛选与推荐>>
1、react-native轮播图(refs)
2、网络流
3、什么叫灰度图
4、2018-2019-1 20165209 《信息安全系统设计基础》第九周学习总结
5、系统讲解——更好的实施专案(Porject)


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号