1, about UNIX sockets
1.1 What is a socket?
The socket is a network file descriptor. In the socket based programming technology, the user does not directly access the network interface device to send and receive packets, but establishes an intermediate file descriptor to handle the operation of the programming interface to the network.
What does the 1.2 socket include?
A special communication domain, such as a network connection
A particular type of communication, such as a stream or datagram.
A special protocol, such as TCP or UDP.
1.3 UNIX socket () C function Detailed description:
int socket (int domain, int type, int protocol)
Values in domain:
Pf_unix UNIX IPC Communication
Pf_inet IPV4 Communication
Pf_inet6ipv6
Pf_ipx Novell IPX
Pf_netlinkkernel user Interface Driver
Pf_x25 X.25
pf_ax25
PF_ATMPVCATM PVC
Pf_appletalkappletalk protocol
Pf_packet low-Level packet interface
Value of type:
Sock_stream using connection-oriented communication packs
Sock_dgram use of connectionless communication packets
Sock_seqpacket uses a connection-oriented communication packet with a fixed maximum length
Sock_raw using the original IP packet
SOCK_RDM Reliable datagram using an order of no guarantee
Protocol:
Typically, the default protocol corresponding to type is used, expressed in 0.
For example: int newsocket = socket (pf_inet, sock_stream, 0);//Using TCP