xref: /minix/minix/man/man2/socket.2 (revision c5da0dff)
SOCKET 2
NAME
socket - creates a socket.
SYNOPSIS
#include <sys/socket.h> int socket(int domain, int type, int protocol);

DESCRIPTION
socket() creates a socket in the specified domain. A socket is a communications endpoint. Currently two values are supported for domain, PF_INET for internet sockets and PF_UNIX for local unix domain sockets. The type of socket can be SOCK_STREAM for TCP sockets in the PF_INET domain or SOCK_DGRAM for UDP sockets in the PF_INET domain. For sockets in the PF_UNIX domain, SOCK_STREAM, SOCK_DGRAM, and SOCK_SEQPACKET are supported values for type. The value of protocol is always 0 or IPPROTO_TCP for TCP sockets or IPPROTO_UDP for UDP sockets.
RETURN VALUES
On success, this function returns a numeric socket descriptor. On error, -1 is returned and errno is set.
ERRORS

15 [EAFNOSUPPORT] The domain is not supported.

15 [EPROTOTYPE] The protocol is not supported by the domain.

15 [EMFILE] The process descriptor table is full.

15 [ENFILE] The system descriptor table is full.

15 [ENOSPC] Could not allocate a file descriptor.

SEE ALSO
socketpair(2), bind(2), listen(2), accept(2), connect(2), shutdown(2), getsockopt(2), setsockopt(2), unix(8)