The socket() system call creates one end of the socket.
int socket(int <family>, int <type>, int <protocol>);
The socket() system call returns the socket descriptor, a small integer that is similar to the file descriptor used in other system calls. For example:
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int sockfd; sockfd = socket(AF_UNIX, SOCK_STREAM, 0);