The socket() call allocates a socket data structure within the
kernel. It returns a descriptor that will be used to refer to the
socket in later function calls.
PF_UNIX specifies that this will be a Unix Domain Socket,
while SOCK_DGRAM specifies that this will be a connectionless,
datagram socket.
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
...
int s;
s = socket (PF_UNIX, SOCK_DGRAM, 0);
if (s < 0) perror ("socket() failed");
|