The socket() system call creates one end of the socket.

int socket(int <family>, int <type>, int <protocol>);

The first parameter specifies the communication family, AF_UNIX or AF_INET.

The second parameter specifies the socket type, SOCK_STREAM or SOCK_DGRAM.

The third parameter is usually zero because communication families usually have only one 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);