Linux Network Programming - socket option

  

computer shop News

1 getsockopt and setsockopt int getsockopt (int sockfd, int level, int optname, void * optval, socklen_t * optlen) int setsockopt (int sockfd, int level, int optname, const void * optval, socklen_t * optlen) level of the socket-level control can take three values:. 1) SOL_SOCKET: General socket option 2) IPPROTO_IP:. IP option 3. IPPROTO_TCP: TCP option. optname specifies the way of control (the name of the option), we explain in detail below optval get or set the socket option. Convert according to the data type of the option name Option name description data type ====== =========================================================== ================ SOL_SOCKET --------------------------------- --------------------------------------- SO_BROADCAST Allows sending broadcast data int SO_DEBUG Allows debugging int SO_DONT ROUTE int the SO_ERROR obtained without searching the routing socket error int int the SO_LINGER the SO_KEEPALIVE remain connected to close the connection delay struct linger SO_OOBINLINE band data into the normal data stream receiver buffer size the SO_RCVBUF int int int SO_RCVLOWAT the SO_SNDBUF transmission buffer size limit receive buffer int SO_SNDLOWAT send buffer limit int SO_RCVTIMEO receive timeout struct timeval SO_SNDTIMEO send the timeout struct timeval SO_REUSERADDR allow reuse of local address and port int SO_TYPE obtained socket type int SO_B SDCOMPAT is compatible with BSD system int ==================================================== ===================================== IPPROTO_IP ------------------- -------------------------------------------------- ----- IP_HDRINCL contains the IP header int IP_OPTINOS IP header options int IP_TOS service type int ======================== IP_TTL survival time in the packet =========================================================== IPPRO_TCP ------------------------------------------------- ------------------------- TCP_MAXSEG TCP maximum data segment size int TCP_NODELAY does not use Nagle algorithm int =========== =========================================================== ============ For more information on these options, please see Linux Programmer's Manual 2 ioctl ioc Tl can control all file descriptors. Here is an introduction to the options for controlling sockets. int ioctl(int fd,int req,...) ================ =========================================================== ======== ioctl control options -------------------------------------- ------------------------------------ SIOCATMARK Whether to reach the out-of-band tag int FIOASYNC Asynchronous input/output flag int FIONREAD Buffer Readable Bytes int ================================================ =================================== Detailed options please use man ioctl_list to view.

Copyright © Windows knowledge All Rights Reserved