Linux socket
来源:互联网 发布:51单片机电子音响 编辑:程序博客网 时间:2024/06/05 19:01
Linux 系统的好工具: man
"man socket" or "man 2 socket":
socket - create an endpoint for communication
int socket(int domain, int type, int protocol);
socket() creates an endpoint for communication and returns a descriptor.
1. The "domain" argument specifies a communication domain; this selects the protocol family which will be used for communication:
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)
2. The "socket" has the indicated type, which specifies the communication semantics:
SOCK_STREAM Provides sequenced, reliable, two-way, connection-based byte streams. An out-of-band data transmission mechanism may be supported.
SOCK_DGRAM Supports datagrams (connectionless, unreliable messages of a fixed maximum length).
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_RAW Provides raw network protocol access.
SOCK_RDM Provides a reliable datagram layer that does not guarantee ordering.
SOCK_PACKET Obsolete and should not be used in new programs; see packet(7).
Some socket types may not be implemented by all protocol families; for example, SOCK_SEQPACKET is not implemented for AF_INET.
Since Linux 2.6.27, the type argument serves a second purpose: in addition to specifying a socket type, it may include the bitwise OR of any of the following
values, to modify the behavior of socket():
SOCK_NONBLOCK Set the O_NONBLOCK file status flag on the new open file description. Using this flag saves extra calls to fcntl(2) to achieve the same result.
SOCK_CLOEXEC Set the close-on-exec (FD_CLOEXEC) flag on the new file descriptor. See the description of the O_CLOEXEC flag in open(2) for reasons why this
may be useful.
3. The "protocol" specifies a particular protocol to be used with the 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. However, it is possible that many protocols may exist, in which case a particular protocol
must be specified in this manner.
4. man 7 unix
unix - sockets for local interprocess communication
The AF_UNIX (also known as AF_LOCAL) socket family is used to communicate between processes on the same machine efficiently.
Traditionally, UNIX domain sockets can be either unnamed, or bound to a filesystem pathname (marked as being of type socket).???
Linux also supports an abstract namespace which is independent of the filesystem.???
5. man 7 ip
ip - Linux IPv4 protocol implementation
Linux implements the Internet Protocol, version 4, described in RFC 791 and RFC 1122.
An IP socket is created by calling the socket(2) function as socket(AF_INET, socket_type, protocol).
6. man 7 netlink
netlink - communication between kernel and user space (AF_NETLINK)
Netlink is used to transfer information between kernel and user-space processes.
7. man 7 packet
packet - packet interface on device level
Packet sockets are used to receive or send raw packets at the device driver (OSI Layer 2) level.
They allow the user to implement protocol modules in user space on top of the physical layer.
8.
- linux socket
- socket linux
- linux + socket
- linux socket
- linux socket
- Linux socket
- linux socket
- linux socket
- Linux Socket
- Linux socket
- linux socket
- linux socket
- linux socket
- Linux Socket
- linux socket
- Linux socket
- linux socket
- 【Linux】socket
- JavaScript快速入门(一)——JavaScript概览
- (每日一练)c++程序设计--谭浩强
- Mybatis入门学习篇(二)之基于注解的增删改查
- 关于iOS中的短连接方法
- POJ 2228 Naptime 环状DP
- Linux socket
- 数据结构算法——网络资源篇
- 4-2-2 多重循环-break跳出
- NAT连接方式连接主机和vmware--给虚拟机上的linux配置ip
- uva1593 Alignment of Code 习题5-1 战胜心魔觅自我!
- Numbering Paths - UVa 125 Floyd求环
- Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use
- Ubuntu下安装中文输入法
- SVN简介