残梦ming 的学生作业:
int socket(int domain, int type, int protocol);
DESCRIPTION
socket() creates an endpoint for communication and returns a file descriptor that refers to that endpoint. The file descriptor returned by a successful call will be
the lowest-numbered file descriptor not currently open for the process.
socket()创建一个用于通信的终端,返回指向该终端的文件描述符
调用成功将返回文件描述符,该文件描述符将会当前未打开进程的最小文件描述符
The domain argument specifies a communication domain; this selects the protocol family which will be used for communication. These families are defined in . The currently understood formats include:
domain参数表示一个通信领域,这个选择的协议将会被用于通讯.这些通信协议被定义在文件.目前可以理解的格式包括
Name Purpose Man page
AF_UNIX, AF_LOCAL Local communication unix(7)
AF_INET IPv4 Internet protocols ip(7)
AF_INET6 IPv6 Internet protocols ipv6(7)
AF_IPX IPX - Novell protocols
AF_NETLINK Kernel user interface device netlink(7)
AF_X25 ITU-T X.25 / ISO-8208 protocol x25(7)
AF_AX25 Amateur radio AX.25 protocol
AF_ATMPVC Access to raw ATM PVCs
AF_APPLETALK AppleTalk ddp(7)
AF_PACKET Low level packet interface packet(7)
AF_ALG Interface to kernel crypto API
The socket has the indicated type, which specifies the communication semantics. Currently defined types are:
socket有明确的类别,这指定通信语义.定义的类型如下:
SOCK_STREAM Provides sequenced, reliable, two-way, connection-based byte streams. An out-of-band data transmission mechanism may be supported.
SOCKET_STREAM 提供有序、可靠、双通道、基于字节流的通信.可支持外带数据传输机制
SOCK_DGRAM Supports datagrams (connectionless, unreliable messages of a fixed maximum length).
SOCKET_DGRAM 支持数据报(固定长度的无连接、不可靠的消息)
SOCK_SEQPACKET Provides a sequenced, reliable, two-way connection-based data transmission path for datagrams of fixed maximum length; a consumer is required to read an entire packet with each input system call.
SOCK_SEQPACKET 为固定最大长度的数据报提供一个有序、可靠、基于双向连接的数据传输路径
SOCK_RAW Provides raw network protocol access.
SOCK_RAW 提供原生网络协议许可
SOCK_RDM Provides a reliable datagram layer that does not guarantee ordering.
SOCKET_RDM 提供一个不保证排序的可靠数据报层,
The protocol specifies a particular protocol to be used with the socket.
协议指定socket使用特定的协议
Normally only a single protocol exists to support a particular socket type within a given protocol family, in which case protocol can be specified as 0.
通常在指定协议族中,只有一个特定的协议存在以支持特别的socket类型,在这种情况下可以被赋值为0
However, it is possible that many protocols may exist, in which case a particular protocol must be specified in this manner.
然而,可能有很多协议存在,这种情况下必须指定一个特定的协议