The primitive for creating a socket is the socket function, declared in `sys/socket.h'.
PF_FILE (see File Namespace) or PF_INET (see Internet Namespace). protocol designates the specific protocol (see Socket Concepts); zero is usually right for protocol.
The return value from socket is the file descriptor for the new socket, or -1 in case of error. The following errno error conditions are defined for this function:
EPROTONOSUPPORT
EMFILE
ENFILE
EACCESS
ENOBUFS
The file descriptor returned by the socket function supports both read and write operations. But, like pipes, sockets do not support file positioning operations.
For examples of how to call the socket function, see File Namespace, or Inet Example.