精品欧美一区二区三区在线观看 _久久久久国色av免费观看性色_国产精品久久在线观看_亚洲第一综合网站_91精品又粗又猛又爽_小泽玛利亚一区二区免费_91亚洲精品国偷拍自产在线观看 _久久精品视频在线播放_美女精品久久久_欧美日韩国产成人在线

socket 中文man頁(yè)面

系統(tǒng)
本手冊(cè)頁(yè)介紹了 Linux 套接字的用戶(hù)接口. 這個(gè) BSD 兼容套接字是介于用戶(hù)進(jìn)程與內(nèi)核網(wǎng)絡(luò)協(xié)議棧之間的統(tǒng)一接口, 各協(xié)議模塊屬于不同的 協(xié)議族 ,如 PF_INET, PF_IPX, PF_PACKET 和 套接字類(lèi)型 ,如 字節(jié)流(SOCK_STREAM) 或 數(shù)據(jù)報(bào)(SOCK_DGRAM). 關(guān)于協(xié)議族和套接字類(lèi)型請(qǐng)參考 socket(2).

NAME

socket - Linux 套接字  

總覽

#include <sys/socket.h>
mysocket = socket(int socket_family, int socket_type, int protocol);

描述

本手冊(cè)頁(yè)介紹了 Linux 套接字的用戶(hù)接口. 這個(gè) BSD 兼容套接字是介于用戶(hù)進(jìn)程與內(nèi)核網(wǎng)絡(luò)協(xié)議棧之間的統(tǒng)一接口, 各協(xié)議模塊屬于不同的 協(xié)議族 ,如 PF_INET, PF_IPX, PF_PACKET套接字類(lèi)型 ,如 字節(jié)流(SOCK_STREAM)數(shù)據(jù)報(bào)(SOCK_DGRAM). 關(guān)于協(xié)議族和套接字類(lèi)型請(qǐng)參考 socket(2).

套接層函數(shù)

用戶(hù)通過(guò)這些套接字函數(shù)發(fā)送和接收包, 以及其他套接字操作. 詳細(xì)說(shuō)明參看他們各自的手冊(cè)頁(yè).

socket(2) 創(chuàng)建套接字,

connect(2) 與遠(yuǎn)程套接字地址建立連接

bind(2) 把套接字和一個(gè)本地套接字地址綁定在一起(為套接字分配一個(gè)本地協(xié)議地址)

listen(2) 通知套接字接受新的連接

accept(2) 為新的已完成連接獲得新的描述字

socketpair(2) 返回兩個(gè)連接的匿名套接字(僅在某些本地族中才有實(shí)現(xiàn),如 PF_UNIX

send(2),

sendto(2), 和 sendmsg(2) 通過(guò)套接字發(fā)送數(shù)據(jù),而 recv(2), recvfrom(2), recvmsg(2) 從套接字接收數(shù)據(jù). poll(2) 和

select(2) 等待數(shù)據(jù)到來(lái)或準(zhǔn)備好接收數(shù)據(jù). 除此之外, 標(biāo)準(zhǔn) I/O 操作如 write(2), writev(2), sendfile(2), read(2), 和 readv(2) 也可用來(lái)讀入(接收)和寫(xiě)出(發(fā)送)數(shù)據(jù).

getsockname(2) 用于獲得本地套接字地址

getpeername(2) 用于獲得遠(yuǎn)端套接字地址. getsockopt(2) 和 setsockopt(2) 用于設(shè)置或取得套接字或協(xié)議選項(xiàng). ioctl(2) 也可以用來(lái)設(shè)置或讀取一些其他選項(xiàng).

close(2) 關(guān)閉套接字. shutdown(2) 關(guān)閉全雙工套接字連接的一部分.

套接字不支持搜索,也不支持調(diào)用 pread(2) 或 pwrite(2) 進(jìn)行非 0 位置的操作. 可以用 fcntl(2). 設(shè)置 O_NONBLOCK 標(biāo)志來(lái)實(shí)現(xiàn)對(duì)套接字的非阻塞 I/O 操作 O_NONBLOCK 是從 accept 繼承來(lái)的,然后原來(lái)所有會(huì)阻塞的操作會(huì)返回 EAGAIN. connect(2) 在此情況下返回 EINPROGRESS 錯(cuò)誤. 用戶(hù)可以通過(guò) poll(2) 或者 select(2) 等待各種事件.

I/O 事件
 
事件 輪詢(xún)標(biāo)志 發(fā)生事件
 
POLLIN 新數(shù)據(jù)到達(dá).
 
POLLIN (對(duì)面向連接的套接字)建立連接成功
 
POLLHUP 另一端套接字發(fā)出斷開(kāi)連接請(qǐng)求.
 
POLLHUP (僅對(duì)面向連接協(xié)議)套接字寫(xiě)的時(shí)候連接斷開(kāi). 同時(shí)發(fā)送 SIGPIPE.
 
寫(xiě) POLLOUT 套接字有充足的發(fā)送緩沖區(qū)用于寫(xiě)入新數(shù)據(jù).
 
讀/寫(xiě) POLLIN|
POLLOUT
發(fā)出的 connect(2) 結(jié)束.
 
讀/寫(xiě) POLLERR 產(chǎn)生一個(gè)異步錯(cuò)誤.
 
讀/寫(xiě) POLLHUP 對(duì)方已經(jīng)單向關(guān)閉連接.
 
例外 POLLPRI 緊急數(shù)據(jù)到達(dá).然后發(fā)送 SIGURG.
 

另外一個(gè)的 poll/select 方法是讓內(nèi)核用 SIGIO 信號(hào)來(lái)通知應(yīng)用程序. 要這么用的話(huà)你必須用 fcntl(2) 設(shè)置套接字文件描述符的 FASYNC 標(biāo)志,并用 sigaction(2). 給 SIGIO 信號(hào)設(shè)置一個(gè)的有效信號(hào)處理句柄.參看下面的 SIGNALS 的討論.  

套接字選項(xiàng)

套接字選項(xiàng)可以用 setsockopt(2) 來(lái)設(shè)置,用 getsockopt(2) 讀取所有套接字級(jí)別設(shè)為 SOL_SOCKET 的套接字的套接字選項(xiàng):

SO_KEEPALIVE
允許在面向連接的套接字上發(fā)送 keep-alive 消息的功能.是一個(gè)布爾整數(shù).
SO_OOBINLINE
如果打開(kāi)這個(gè)選項(xiàng),帶外(Out-of-Band)數(shù)據(jù)可以直接放入接收數(shù)據(jù)流。否則,只有接收時(shí)打開(kāi) MSG_OOB 標(biāo)志, 才接收帶外數(shù)據(jù).
SO_RCVLOWATSO_SNDLOWAT
聲明在開(kāi)始向協(xié)議 (SO_SNDLOWAT) 或正在接收數(shù)據(jù)的用戶(hù) (SO_RCVLOWAT). 傳遞數(shù)據(jù)之前緩沖區(qū)內(nèi)的最小字節(jié)數(shù). 在 Linux 中這兩個(gè)值是不可改變的, 固定為 1 字節(jié). 可以用 getsockopt 用來(lái)讀取它們的值; setsockopt 總是返回 ENOPROTOOPT.
SO_RCVTIMEOSO_SNDTIMEO
發(fā)送和接收時(shí)的超時(shí)設(shè)定, 并在超時(shí)時(shí)報(bào)錯(cuò). 在 Linux 中由協(xié)議指定, 不能被讀寫(xiě). 它們的功能可用 alarm(2) 或者 setitimer(2). 來(lái)模擬.
SO_BSDCOMPAT
允許 BSD 的 bug-to-bug 兼容. 這一項(xiàng)只能在 UDP 協(xié)議模塊中使用而且今后將要取消. 如果允許的話(huà), UDP 套接字接收到的 ICMP 錯(cuò)誤將不會(huì)被傳送至用戶(hù)程序. Linux 2.0 中對(duì)于原始套接字也允許 BSD bug-to-bug 兼容(報(bào)頭隨機(jī)改變,省略廣播標(biāo)識(shí)),但在 Linux 2.2 中取消了這一項(xiàng). 修改用戶(hù)程序的方式比較好.
SO_PASSCRED
允許或關(guān)閉 SCM_CREDENTIALS 控制消息的接收. 更多信息參見(jiàn) unix(7).
SO_PEERCRED
返回連接至此套接字的外部進(jìn)程的身份驗(yàn)證. 只在 PF_UNIX 套接字中有用.參見(jiàn) unix(7). 參數(shù)為 ucred 結(jié)構(gòu).只在 getsockopt. 中有效.
SO_BINDTODEVICE
將此套接字綁定到一個(gè)特定的設(shè)備上, 如lqeth0rq, 做為指定的接口名字傳遞. 如果名稱(chēng)是空字符串或此項(xiàng)長(zhǎng)度為 0, 則套接字設(shè)備綁定被取消. 過(guò)去的選項(xiàng)是一個(gè)變長(zhǎng)的空零結(jié)尾的接口名稱(chēng)的字符串, 其最大長(zhǎng)度為 IFNAMSIZ. 如果一個(gè)套接字被綁定至一接口, 只有由這個(gè)特定接口接收的信息包可以由此套接字處理.
SO_DEBUG
允許套接字調(diào)試.只對(duì)有 CAP_NET_ADMIN 功能或有效用戶(hù)標(biāo)識(shí)為 0 的進(jìn)程有效.
SO_REUSEADDR
表示在一個(gè) bind(2) 調(diào)用中對(duì)提供給它的地址使用的確認(rèn)規(guī)則應(yīng)該允許重復(fù)使用本地地址. 對(duì)于 PF_INET 套接字, 這表示該套接字可以綁定, 除非已有一個(gè)活躍的偵聽(tīng)套接口綁定到此地址上. 如果這個(gè)偵聽(tīng)套接字和一個(gè)指定端口綁定為 INADDR_ANY 時(shí), 它就不能再綁定到任何本地地址的此端口.
SO_TYPE
按整數(shù)返回套接字類(lèi)型(如 SOCK_STREAM) 只能通過(guò) getsockopt 讀取.
SO_DONTROUTE
不通過(guò)網(wǎng)關(guān)發(fā)送, 只能發(fā)送給直接連接的主機(jī).可以通過(guò)在套接字的 send(2) 操作上設(shè)置 MSG_DONTROUTE 標(biāo)志來(lái)實(shí)現(xiàn)相同的效果. 其值為布爾型整數(shù)的標(biāo)識(shí).
SO_BROADCAST
設(shè)置或獲取廣播標(biāo)識(shí). 當(dāng)選擇此選項(xiàng)時(shí), 數(shù)據(jù)報(bào)套接字接收向廣播地址發(fā)送的數(shù)據(jù)包, 并且可以向廣播地址發(fā)送數(shù)據(jù)包. 這一選項(xiàng)對(duì)于面向流的套接字無(wú)效.
SO_SNDBUF
設(shè)置或得到套接字發(fā)送緩沖區(qū)的最大字節(jié)數(shù). 其默認(rèn)值由 wmem_default sysctl 設(shè)置,最大允許值由 wmem_max sysctl 設(shè)置.
SO_RCVBUF
設(shè)置或得到套接字接收緩沖區(qū)的最大字節(jié)數(shù)。其默認(rèn)值由 rmem_default sysctl設(shè)置,最大允許值由 rmem_max sysctl 設(shè)置.
SO_LINGER
設(shè)置或獲取 SO_LINGER 選項(xiàng)的值. 其參數(shù)為 linger 結(jié)構(gòu).
struct linger {
    int   l_onoff;    /* 延時(shí)狀態(tài)(打開(kāi)/關(guān)閉) */
    int   l_linger;   /* 延時(shí)多長(zhǎng)時(shí)間 */
};

如果選擇此選項(xiàng), close(2) 或 shutdown(2) 將等到所有套接字里排隊(duì)的消息成功發(fā)送或到達(dá)延遲時(shí)間后才會(huì)返回. 否則, 調(diào)用將立即返回. 而 closing 操作將在后臺(tái)進(jìn)行. 如果套接字是 exit(2), 的一部分關(guān)閉時(shí), 它總是在后臺(tái)延遲進(jìn)行的.
SO_PRIORITY
設(shè)置在此套接字發(fā)送的所有包的協(xié)議定義優(yōu)先權(quán). Linux 通過(guò)這一值來(lái)排列網(wǎng)絡(luò)隊(duì)列: 根據(jù)所選設(shè)備排隊(duì)規(guī)則, 具有更高優(yōu)先權(quán)的包可以先被處理.對(duì)于 ip(7), 同時(shí)也設(shè)置了輸出包的 IP 服務(wù)類(lèi)型(TOS)的域.
SO_ERROR
取得并清除未解決的套接字錯(cuò)誤. 只有在 getsockopt. 時(shí)有效. 是一個(gè)整數(shù)值.

SIGNALS

當(dāng)向一個(gè)已關(guān)閉(被本地或遠(yuǎn)程終端)的面向聯(lián)接的套接字寫(xiě)入時(shí), 將向該寫(xiě)入進(jìn)程發(fā)送 SIGPIPE 信號(hào),并返回 EPIPE 如果寫(xiě)入命令聲明了 MSG_NOSIGNAL 標(biāo)識(shí)時(shí), 不會(huì)發(fā)出此信號(hào).

如果與 FIOCSETOWN fcntl 或 SIOCSPGRP ioctl 一起請(qǐng)求,那么當(dāng)發(fā)生 I/O 事件時(shí)發(fā)出 SIGIO 這樣我們就可以在信號(hào)句柄里使用 poll(2) 或 select(2) 找出發(fā)生事件的套接字. 另一種選擇(在 Linux 2.2 中)是用 F_SETSIG fcntl 設(shè)置一個(gè)實(shí)時(shí)信號(hào): 實(shí)時(shí)信號(hào)的處理程序被調(diào)用時(shí)還會(huì)收到它的 siginfo_tsi_fd 區(qū)域中的文件描述符. 更多信息參見(jiàn) fcntl(2)

在某些環(huán)境中(例如:多個(gè)進(jìn)程訪問(wèn)單個(gè)套接字), 引發(fā) SIGIO 的東西在進(jìn)程對(duì)信號(hào)作出反應(yīng)時(shí)可能已經(jīng)消失了. 如果這樣的話(huà), 進(jìn)程應(yīng)該再次等待, 因?yàn)?Linux 稍后會(huì)重發(fā)此信號(hào).  

SYSCTLS

可以通過(guò)目錄 /proc/sys/net/core/* 下的文件或者用 sysctl(2) 系統(tǒng)調(diào)用來(lái)訪問(wèn)內(nèi)核套接字的網(wǎng)絡(luò)系統(tǒng)控制(sysctl)信息.

rmem_default
指明套接字接收緩沖區(qū)的默認(rèn)字節(jié)數(shù).
rmem_max
指明套接字接收緩沖區(qū)的最大字節(jié)數(shù), 用戶(hù)可以通過(guò)使用 SO_RCVBUF 套接字選項(xiàng)來(lái)設(shè)置此值.
wmem_default
指明套接字發(fā)送緩沖區(qū)的默認(rèn)字節(jié)數(shù).
wmem_max
指明發(fā)送緩沖區(qū)的最大字節(jié)數(shù),用戶(hù)可以通過(guò)使用套接字的 SO_SNDBUF 選項(xiàng)來(lái)設(shè)置它的值.
message_costmessage_burst
設(shè)定記號(hào)存儲(chǔ)桶過(guò)濾器, 在存儲(chǔ)桶中保存一定數(shù)量的外部網(wǎng)絡(luò)事件導(dǎo)致的警告消息.
netdev_max_backlog
在全局輸入隊(duì)列中包的最大數(shù)目.
optmem_max
每個(gè)套接字的象 iovecs 這樣的輔助數(shù)據(jù)和用戶(hù)控制數(shù)據(jù)的最大長(zhǎng)度.

IOCTLS

以上的 IO 控制值可以通過(guò) ioctl(2) 來(lái)訪問(wèn):

error = ioctl(ip_socket, ioctl_type, &value_result);
SIOCGSTAMP
返回 timeval 類(lèi)型的結(jié)構(gòu),其中包括有發(fā)送給用戶(hù)的最后一個(gè)包接收時(shí)的時(shí)間戳。被用來(lái)測(cè)量精確的 RTT (round trip time) 時(shí)間. struct timeval. 結(jié)構(gòu)說(shuō)明請(qǐng)參考 setitimer(2)
SIOCSPGRP
在異步 IO 操作結(jié)束或者接收到緊急數(shù)據(jù)時(shí),用來(lái)設(shè)置進(jìn)程或進(jìn)程組,向它(它們)發(fā)送 SIGIO 或者 SIGURG 信號(hào), 參數(shù)為指向 pid_t. 類(lèi)型的指針。如果參數(shù)為正,則發(fā)送信號(hào)到相應(yīng)的進(jìn)程。如果參數(shù)為負(fù),則發(fā)送信號(hào)到此參數(shù)絕對(duì)值 id 所屬的進(jìn)程組的所有進(jìn)程。如果它沒(méi)有 CAP_KILL 功能或者它的有效 UID 不是 0, 進(jìn)程只能選擇它自己或自己的進(jìn)程組來(lái)接收信號(hào).
FIOASYNC
改變 O_ASYNC 標(biāo)志來(lái)打開(kāi)或者關(guān)閉套接字的異步 IO 模式。異步IO模式指的是:當(dāng)新的 I/O 事件發(fā)生時(shí),將發(fā)出 SIGIO 信號(hào)或者用 F_SETSIG 設(shè)置的信號(hào).
參數(shù)為整形布爾量.
SIOCGPGRP
獲得當(dāng)前接收 SIGIO 或者 SIGURG 信號(hào)的進(jìn)程或者進(jìn)程組, 如果兩個(gè)信號(hào)都沒(méi)有設(shè)置, 則為 0.

有效的 fcntl:

FIOCGETOWN
與 IO 控制中的 SIOCGPGRP 相同.
FIOCSETOWN
與 IO 控制中的 SIOCSPGRP 相同.

注意

Linux 假設(shè)有一半的發(fā)送/接收緩沖區(qū)是用來(lái)處理內(nèi)核結(jié)構(gòu), 因此, 系統(tǒng)控制的緩沖區(qū)是網(wǎng)絡(luò)可訪問(wèn)的緩沖區(qū)的兩倍.  

缺陷

CONFIG_FILTER 沒(méi)有介紹 SO_ATTACH_FILTER SO_DETACH_FILTER 套接字選項(xiàng). 在 libpcap 庫(kù)有此接口的說(shuō)明  

VERSIONS 版本

SO_BINDTODEVICE 在 Linux 2.0.30 中引入. SO_PASSCRED 是在 Linux 2.2 中引入的新選項(xiàng). sysctl 是在 Linux 2.2. 中引入的新概念。  

作者

本手冊(cè)頁(yè)由 Andi Kleen 編寫(xiě).

又見(jiàn)

socket(2), ip(7), setsockopt(2), getsockopt(2), packet(7), ddp(7)

#p#

NAME

socket - Linux socket interface  

SYNOPSIS

#include <sys/socket.h>
mysocket = socket(int socket_family, int socket_type, int protocol);

DESCRIPTION

This manual page describes the Linux networking socket layer user interface. The BSD compatible sockets are the uniform interface between the user process and the network protocol stacks in the kernel. The protocol modules are grouped into protocol families like PF_INET, PF_IPX, PF_PACKET and socket types like SOCK_STREAM or SOCK_DGRAM. See socket(2) for more information on families and types.

SOCKET LAYER FUNCTIONS

These functions are used by the user process to send or receive packets and to do other socket operations. For more information see their respective manual pages.

socket(2) creates a socket, connect(2) connects a socket to a remote socket address, the bind(2) function binds a socket to a local socket address, listen(2) tells the socket that new connections shall be accepted, and accept(2) is used to get a new socket with a new incoming connection. socketpair(2) returns two connected anonymous sockets (only implemented for a few local families like PF_UNIX)

send(2), sendto(2), and sendmsg(2) send data over a socket, and recv(2), recvfrom(2), recvmsg(2) receive data from a socket. poll(2) and select(2) wait for arriving data or a readiness to send data. In addition, the standard I/O operations like write(2), writev(2), sendfile(2), read(2), and readv(2) can be used to read and write data.

getsockname(2) returns the local socket address and getpeername(2) returns the remote socket address. getsockopt(2) and setsockopt(2) are used to set or get socket layer or protocol options. ioctl(2) can be used to set or read some other options.

close(2) is used to close a socket. shutdown(2) closes parts of a full duplex socket connection.

Seeking, or calling pread(2) or pwrite(2) with a non-zero position is not supported on sockets.

It is possible to do non-blocking IO on sockets by setting the O_NONBLOCK flag on a socket file descriptor using fcntl(2). Then all operations that would block will (usually) return with EAGAIN (operation should be retried later); connect(2) will return EINPROGRESS error. The user can then wait for various events via poll(2) or select(2).

I/O events
 
Event Poll flag Occurrence
 
Read POLLIN New data arrived.
 
Read POLLIN A connection setup has been completed (for connection-oriented sockets)
 
Read POLLHUP A disconnection request has been initiated by the other end.
 
Read POLLHUP A connection is broken (only for connection-oriented protocols). When the socket is written SIGPIPE is also sent.
 
Write POLLOUT Socket has enough send buffer space for writing new data.
 
Read/Write POLLIN|
POLLOUT
An outgoing connect(2) finished.
 
Read/Write POLLERR An asynchronous error occurred.
 
Read/Write POLLHUP The other end has shut down one direction.
 
Exception POLLPRI Urgent data arrived. SIGURG is sent then.
 

An alternative to poll/select is to let the kernel inform the application about events via a SIGIO signal. For that the FASYNC flag must be set on a socket file descriptor via fcntl(2) and a valid signal handler for SIGIO must be installed via sigaction(2). See the SIGNALS discussion below.  

SOCKET OPTIONS

These socket options can be set by using setsockopt(2) and read with getsockopt(2) with the socket level set to SOL_SOCKET for all sockets:

SO_KEEPALIVE
Enable sending of keep-alive messages on connection-oriented sockets. Expects a integer boolean flag.
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_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 not changeable in Linux and their argument size is always fixed to 1 byte. getsockopt is able to read them; setsockopt will always return ENOPROTOOPT.
SO_RCVTIMEO and SO_SNDTIMEO
Specify the receiving or sending timeouts until reporting an error. The parameter is a struct 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_BSDCOMPAT
Enable BSD bug-to-bug compatibility. This is used only by the UDP protocol module and scheduled to be removed in future. If enabled ICMP errors received for a UDP socket will not be passed to the user program. 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 has been removed in Linux 2.2. It is better to fix the user programs than to enable this flag.
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. Only useful for PF_UNIX sockets; see unix(7). Argument is a ucred structure. Only valid as a getsockopt.
SO_BINDTODEVICE
Bind this socket to a particular device like lqeth0rq, 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, particularly AF_INET sockets. It is not supported for packet sockets (use normal bind(8) there).
SO_DEBUG
Enable socket debugging. Only allowed for processes with the CAP_NET_ADMIN capability or an effective user id of 0.
SO_REUSEADDR
Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. For PF_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.
SO_TYPE
Gets the socket type as an integer (like SOCK_STREAM). Can only be read with getsockopt.
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. Can only be read with getsockopt.
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_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_SNDBUF
Sets or gets the maximum socket send buffer in bytes. The default value is set by the wmem_default sysctl and the maximum allowed value is set by the wmem_max sysctl.
SO_RCVBUF
Sets or gets the maximum socket receive buffer in bytes. The default value is set by the rmem_default sysctl and the maximum allowed value is set by the rmem_max sysctl.
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) 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_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.
SO_ERROR
Get and clear the pending socket error. Only valid as a getsockopt. Expects an integer.

SIGNALS

When writing onto a connection-oriented socket that has been shut down (by the local or the remote end) SIGPIPE is sent to the writing process and EPIPE is returned. The signal is not sent when the write call specified the MSG_NOSIGNAL flag.

When requested with the FIOSETOWN fcntl or SIOCSPGRP ioctl, SIGIO is sent when an I/O event occurs. It is possible to use poll(2) or select(2) in the signal handler to find out which socket the event occurred on. An alternative (in Linux 2.2) is to set a realtime signal using the F_SETSIG fcntl; the handler of the real time signal will be called with the file descriptor in the si_fd field of its siginfo_t. See fcntl(2) for more information.

Under some circumstances (e.g. multiple processes accessing a single socket), the condition that caused the SIGIO may have already disappeared when the process reacts to the signal. If this happens, the process should wait again because Linux will resend the signal later.  

SYSCTLS

The core socket networking sysctls can be accessed using the /proc/sys/net/core/* files or with the sysctl(2) interface.

rmem_default
contains the default setting in bytes of the socket receive buffer.
rmem_max
contains the maximum socket receive buffer size in bytes which a user may set by using the SO_RCVBUF socket option.
wmem_default
contains the default setting in bytes of the socket send buffer.
wmem_max
contains the maximum socket send buffer size in bytes which a user may set by using the SO_SNDBUF socket option.
message_cost and message_burst
configure the token bucket filter used to load limit warning messages caused by external network events.
netdev_max_backlog
Maximum number of packets in the global input queue.
optmem_max
Maximum length of ancillary data and user control data like the iovecs per socket.

IOCTLS

These ioctls can be accessed using ioctl(2):

error = ioctl(ip_socket, ioctl_type, &value_result);
SIOCGSTAMP
Return a struct timeval with the receive timestamp of the last packet passed to the user. This is useful for accurate round trip time measurements. See setitimer(2) for a description of struct timeval.
SIOCSPGRP
Set the process or process group to send SIGIO or SIGURG signals to when an asynchronous I/O operation has finished or urgent data is available. The argument is a pointer to a pid_t. If the argument is positive, send the signals to that process. If the argument is negative, send the signals to the process group with the id of the absolute value of the argument. The process may only choose itself or its own process group to receive signals unless it has the CAP_KILL capability or an effective UID of 0.
FIOASYNC
Change the O_ASYNC flag to enable or disable asynchronous IO mode of the socket. Asynchronous IO mode means that the SIGIO signal or the signal set with F_SETSIG is raised when a new I/O event occurs.
Argument is a integer boolean flag.
SIOCGPGRP
Get the current process or process group that receives SIGIO or SIGURG signals, or 0 when none is set.

Valid fcntls:

FIOGETOWN
The same as the SIOCGPGRP ioctl.
FIOSETOWN
The same as the SIOCSPGRP ioctl

NOTES

Linux assumes that half of the send/receive buffer is used for internal kernel structures; thus the sysctls are twice what can be observed on the wire.  

BUGS

The CONFIG_FILTER socket options SO_ATTACH_FILTER and SO_DETACH_FILTER are not documented. The suggested interface to use them is via the libpcap library.  

VERSIONS

SO_BINDTODEVICE was introduced in Linux 2.0.30. SO_PASSCRED is new in Linux 2.2. The sysctls are new in Linux 2.2. SO_RCVTIMEO and SO_SNDTIMEO are supported since Linux 2.3.41. Earlier, timeouts were fixed to a protocol specific setting, and could not be read or written.  

SEE ALSO

socket(2), ip(7), setsockopt(2), getsockopt(2), packet(7), ddp(7)

責(zé)任編輯:韓亞珊 來(lái)源: CMPP.net
相關(guān)推薦

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-16 10:21:13

setconsole中文man

2011-08-24 17:06:42

NOTIFY中文man

2011-08-16 09:32:01

quotaoff中文man

2011-08-23 18:05:21

ABORT中文man

2011-08-25 18:14:26

tcflow中文man

2011-08-25 16:55:26

gets中文man

2011-08-12 11:07:19

git中文man

2011-08-25 17:30:26

setbuf中文man

2011-08-15 13:14:44

rmdir中文man

2011-08-24 17:00:04

netdevice中文man

2011-11-01 13:46:50

中文mantac

2011-08-15 09:55:01

ls中文man

2011-08-24 16:20:09

load中文man

2011-08-25 15:47:06

fopen中文man

2011-08-25 16:25:30

fputs中文man

2011-08-25 10:49:28

rpc中文man
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

一区二区三区免费观看| 精品在线播放免费| 亚洲精品永久免费精品| 牛夜精品久久久久久久| av网站免费在线观看| www.亚洲人| 国产欧美最新羞羞视频在线观看| 久草成人在线视频| 国产一区二区亚洲| 日韩亚洲欧美高清| 亚欧在线免费观看| 国内老司机av在线| 国产精品天干天干在观线| 91手机在线观看| 成人免费视频国产免费| 午夜日韩视频| 有码中文亚洲精品| 黄色性视频网站| 综合久久伊人| 一本大道av伊人久久综合| 男人天堂网站在线| 888av在线| 2020国产精品自拍| 国产精品一区而去| 91久久久久久久久久久久| 日韩一级精品| 另类色图亚洲色图| 欧美成人短视频| 牲欧美videos精品| 精品国产精品一区二区夜夜嗨| 一区二区三区视频网| 麻豆蜜桃在线观看| 亚洲成a人v欧美综合天堂下载| 在线播放 亚洲| www.亚洲免费| 久久嫩草精品久久久精品| 国产精品欧美久久| 精品久久久中文字幕人妻| 久久99久久久久| 国产黑人绿帽在线第一区| 日韩免费不卡视频| 狠久久av成人天堂| 九九热精品视频在线播放| 婷婷丁香综合网| 欧美精品羞羞答答| 亚洲欧美日韩中文视频| 亚洲精品理论片| 日韩mv欧美mv国产网站| 亚洲国产精品人久久电影| 久久无码专区国产精品s| 国产精品久久免费视频| 91麻豆精品国产91久久久久久久久| 日本爱爱免费视频| jvid一区二区三区| 欧美色大人视频| 无限资源日本好片| 黄页免费欧美| 在线成人av影院| 免费国偷自产拍精品视频| 国产一区二区三区免费在线 | 日韩不卡在线播放| av不卡在线看| 国产成人一区二区三区| 日本成人一级片| 美女任你摸久久| 成人免费网视频| 国产普通话bbwbbwbbw| 韩日av一区二区| 亚洲在线www| 女人18毛片水真多18精品| 99re这里只有精品首页| 蜜桃狠狠色伊人亚洲综合网站| 毛片在线播放网站| 国产精品毛片高清在线完整版| 制服国产精品| 日本在线视频中文有码| 精品国产乱码久久久久酒店| 91蝌蚪视频在线观看| 久久er热在这里只有精品66| 欧美一区二区人人喊爽| 国产精品一区二区无码对白| 免费观看久久av| 日韩三级成人av网| 精品少妇久久久| 三级欧美韩日大片在线看| 国产欧美在线播放| 亚洲AV无码成人片在线观看| 99精品偷自拍| 手机福利在线视频| 久草在线资源站手机版| 欧美日韩一区视频| 国产免费一区二区三区最新6| 在线观看欧美理论a影院| 色婷婷av一区二区三区久久| 免费在线一区二区三区| 丝袜a∨在线一区二区三区不卡| 国产欧美一区二区三区在线 | av日韩在线免费观看| 亚洲成人久久久| 九一在线免费观看| 亚洲精品社区| 成人黄色av网| 日韩a在线观看| 亚洲视频 欧洲视频| 日本毛片在线免费观看| 精品国产18久久久久久二百| 亚洲欧美一区二区三区久久 | 国产高清免费av在线| 亚洲精品中文字幕乱码三区| 欧美激情国产精品日韩| 麻豆久久一区| 中文字幕国产亚洲| 欧美一区二区三区四| 国产一区二区三区在线观看免费视频| 久久久国产精品一区二区三区| 国产黄a三级三级三级av在线看| 欧美性色19p| 熟妇高潮一区二区| 欧美视频福利| 成人福利视频网| 国产黄在线看| 日韩欧美在线视频免费观看| 亚洲视频天天射| 亚洲第一偷拍| 国产精品亚洲片夜色在线| 欧美女优在线| 欧美色欧美亚洲高清在线视频| 日批视频免费看| 国产精品二区不卡| 国产伦精品免费视频| 黄色在线免费观看大全| 欧美日韩在线免费| 少妇精品无码一区二区三区| 欧美涩涩网站| 成人区精品一区二区| 超碰最新在线| 欧美一区二区视频在线观看2022| 夫妇露脸对白88av| 日韩精品一二三四| 日本一区二区三区四区高清视频| 韩国美女久久| 亚洲欧洲一区二区三区久久| 五月婷婷视频在线| 91视频国产资源| 国产免费黄视频| 神马香蕉久久| 热久久美女精品天天吊色| 日本亚洲欧美| 一本色道亚洲精品aⅴ| 美女脱光内衣内裤| 日韩 欧美一区二区三区| 亚洲国产精品www| 成人激情视屏| www.国产精品一二区| 国产精品色综合| 亚洲人成精品久久久久| 三日本三级少妇三级99| 永久91嫩草亚洲精品人人| 91久久精品一区二区别| 3344国产永久在线观看视频| 亚洲国产精品久久久久秋霞不卡| 91精品国产乱码在线观看| 91亚洲永久精品| 99视频在线免费| 久久伦理在线| 国产传媒一区| 涩涩视频网站在线观看| 亚洲偷欧美偷国内偷| 亚洲天堂男人网| 亚洲激情第一区| 亚洲精品中文字幕在线播放| 首页欧美精品中文字幕| 中文字幕一区二区三区乱码 | 亚洲精品一区二区三区樱花| 日韩电影精品| 久久久久久久国产| 九色视频在线播放| 欧美精品一级二级三级| 亚洲精品在线观看av| 久久先锋资源网| 五月天激情播播| 亚洲国产高清一区| 亚洲国产精品一区二区第四页av| 国产不卡精品| 55夜色66夜色国产精品视频 | 亚洲欧洲日产国产综合网| 男插女视频网站| 国产一区二区三区的电影| 五月天色一区| 黄色免费大全亚洲| 国产免费一区二区三区在线观看 | 亚洲高清免费| 日韩欧美在线观看强乱免费| 国产精品一区二区精品| 欧美亚洲成人xxx| 黄a在线观看| 亚洲男子天堂网| 精品国产av一区二区三区| 色综合网色综合| 欧美日韩一级在线观看| 国产日韩综合av| 亚洲一区二区在线免费| 久久www免费人成看片高清| 可以看毛片的网址| 天天天综合网| 欧美一区视久久| 三级欧美日韩| 国产日韩精品入口| 吉吉日韩欧美| 高清欧美电影在线| 国产日产一区二区| 一本色道久久88综合亚洲精品ⅰ| 亚洲AV午夜精品| 欧美日本不卡视频| 黄瓜视频在线免费观看| 亚洲综合久久av| 国产稀缺精品盗摄盗拍| 国产亚洲女人久久久久毛片| 欧美午夜精品一区二区| 国产制服丝袜一区| 久热精品在线观看视频| 玖玖视频精品| 黄色大片中文字幕| 欧美在线亚洲综合一区| 一本一生久久a久久精品综合蜜 | 亚洲精品永久免费精品| 成人午夜视频一区二区播放| 91麻豆精品国产91久久久久| 日韩精品一区二区亚洲av观看| 亚洲va欧美va人人爽午夜| 波多野结衣不卡视频| 国产精品国产精品国产专区不蜜| 欧美激情亚洲色图| 国产亚洲美州欧州综合国| 国产精品无码一区二区三区| av一二三不卡影片| 国模无码视频一区| www.欧美日韩国产在线| 人妻互换一二三区激情视频| 国产成人精品免费在线| 青娱乐精品在线| 国产黄色91视频| 九色91porny| 国产剧情一区二区三区| 激情久久综合网| 国产精品1区2区| xxxx视频在线观看| 成人免费毛片片v| 95视频在线观看| 99久久精品国产导航| 亚洲欧美在线不卡| 久久综合色天天久久综合图片| 亚洲欧美色图视频| 国产日韩精品一区二区浪潮av| 亚洲精品色午夜无码专区日韩| 国产女人aaa级久久久级| 卡一卡二卡三在线观看| 中文字幕一区二区三区乱码在线| 顶臀精品视频www| 亚洲一区二区三区中文字幕在线| 豆国产97在线 | 亚洲| 精品久久香蕉国产线看观看亚洲| 国产污污视频在线观看| 色欧美日韩亚洲| 在线观看中文字幕网站| 欧美一区二区在线不卡| 亚洲经典一区二区三区| 日韩精品亚洲精品| 国产一区二区影视| 欧美尺度大的性做爰视频| av色在线观看| 国产成人精品av| 欧美一级网址| 国产综合色一区二区三区| 五月天亚洲一区| 一本久道久久综合狠狠爱亚洲精品| 久久精品亚洲人成影院 | 蜜桃麻豆影像在线观看| 日韩免费在线观看视频| 国产精品久久免费视频| 精品国产乱码久久久久久久软件| 欧洲乱码伦视频免费| 精品一区二区三区毛片| 亚洲精品美女| 久久99爱视频| 不卡视频一二三| 貂蝉被到爽流白浆在线观看 | 国产精品suv一区| 制服丝袜亚洲色图| 性猛交xxxx| 久久久久北条麻妃免费看| 高清视频在线观看三级| 国产精品视频永久免费播放| 中文字幕av一区二区三区四区| 免费精品视频一区| 国产一区日韩一区| www.精品在线| 99久久精品国产一区二区三区| 国产99在线 | 亚洲| 精品久久久久久亚洲国产300| 中文字幕免费播放| 亚洲第五色综合网| 欧美日韩xx| 欧亚精品中文字幕| 亚洲精品一区国产| 亚洲欧美一区二区原创| 国产一级久久| 中文字幕人妻熟女人妻a片| 国产日韩av一区二区| 国产真实夫妇交换视频| 欧美欧美午夜aⅴ在线观看| 手机福利在线| 欧美高清激情视频| 国产区一区二| 亚洲精品日韩在线观看| 国产一区二区三区久久| 久久久久中文字幕亚洲精品 | 岛国精品在线观看| 久久精品一区二区三区四区五区| 日本韩国视频一区二区| 好吊色视频一区二区| 欧美成人亚洲成人| 91精品福利观看| 伊人久久大香线蕉午夜av| 三级精品在线观看| 91久久免费视频| 欧美小视频在线观看| 日批免费在线观看| 欧美大片免费看| 精品国产亚洲日本| 在线视频不卡一区二区三区| 美日韩一级片在线观看| 一色道久久88加勒比一| 欧美日韩免费观看中文| 视频三区在线观看| 91国产高清在线| 欧美日韩一区二区三区四区不卡| 妞干网视频在线观看| 成人午夜免费av| 国产成人精品av久久| 亚洲精品一区二区三区在线观看| 性欧美猛交videos| 3d精品h动漫啪啪一区二区| 亚洲午夜精品一区 二区 三区| 久久久久久久久久一区| 综合欧美亚洲日本| 国产精品毛片久久久久久久av| 久久久精品一区二区| 欧美少妇激情| 国产又粗又硬又长| 国产在线观看一区二区| 九九九久久久久| 欧美成人乱码一区二区三区| 懂色av一区| 蜜桃网站成人| 视频在线观看一区| 色婷婷国产精品免| 在线综合视频播放| 国产精品69xx| 鲁丝一区二区三区免费| 视频精品一区二区| 国产精品99久久久久久成人| 538在线一区二区精品国产| 大地资源网3页在线观看| 痴汉一区二区三区| 1024日韩| 日本二区在线观看| 欧美巨大另类极品videosbest| av毛片在线看| 精品视频导航| 久久精品久久综合| 久操视频免费在线观看| 国产视频欧美视频| 日本免费在线一区| 国产又大又长又粗又黄| 成人午夜激情影院| 无码人妻一区二区三区免费| 中文字幕亚洲欧美日韩在线不卡 | 亚洲成人久久一区| 香蕉视频亚洲一级| 艳母动漫在线免费观看| 99精品欧美一区| 中文字幕 亚洲视频| 色综合色综合久久综合频道88| 欧美性生活一级片| 一区二区在线免费看| 亚洲午夜精品在线| 成年人视频在线免费观看| 97人人澡人人爽| 日韩精品免费视频人成| 免费在线观看一级片| 亚洲美女喷白浆| 久久久久久亚洲精品美女| 国产精品999视频| 中文字幕日本不卡| 五月婷婷丁香六月| 91在线高清免费观看| 久久蜜桃资源一区二区老牛| 国产一二三四区| 中文字幕av一区|