Creating sockets
Sockets are file descriptors returned by the C socket function.
#include <sys/socket.h>
int socket(int domain, int type, int protocol);
On error socket returns -1 and errno is set to one of the following:
EAFNOSUPPORTEMFILEENFILEEPROTONOSUPPORTEPROTOTYPEEACCESSENOBUFSENOMEM
On success, the function returns the fd of the new socket.
Socket domains
The domain specifies the address family. Valid address families are implementation defined.
Most used
AF_UNIXorAF_LOCALAF_INETAF_INET6
Rarely used
AF_X25AF_AX25AF_IPXAF_APPLETALKAF_DECnetAF_KEYAF_NETLINKAF_PACKETAF_RDSAF_PPPOXAF_LLCAF_IBAF_MPLSAF_CANAF_TIPCAF_BLUETOOTHAF_ALGAF_VSOCKAF_KCMAF_XDP
Socket types
These are valid socket types:
SOCK_STREAM: sequences, relaiable, bidirectional, connection-mode byte stream.SOCK_DGRAM: connectionsless-mode unrelaiable messages of fixed max length.SOCK_SEQPACKET:SOCK_RAW:SOCK_RDM:SOCK_PACKET:SOCK_NONBLOCK:SOCK_CLOEXEC: