.\"
.Dd June 4, 1993
.Dt SOCKET 2
-.Os BSD 4.2
+.Os
.Sh NAME
.Nm socket
.Nd create an endpoint for communication
.Sh SYNOPSIS
-.Fd #include <sys/types.h>
.Fd #include <sys/socket.h>
.Ft int
-.Fn socket "int domain" "int type" "int protocol"
+.Fo socket
+.Fa "int domain"
+.Fa "int type"
+.Fa "int protocol"
+.Fc
.Sh DESCRIPTION
.Fn Socket
creates an endpoint for communication and returns a descriptor.
The currently understood formats are
.Pp
.Bd -literal -offset indent -compact
-AF_UNIX (UNIX internal protocols),
-AF_INET (ARPA Internet protocols),
-AF_ISO (ISO protocols),
-AF_NS (Xerox Network Systems protocols), and
-AF_IMPLINK (IMP \*(lqhost at IMP\*(rq link layer).
+PF_LOCAL Host-internal protocols, formerly called PF_UNIX,
+PF_UNIX Host-internal protocols, deprecated, use PF_LOCAL,
+PF_INET Internet version 4 protocols,
+PF_ROUTE Internal Routing protocol,
+PF_KEY Internal key-management function,
+PF_INET6 Internet version 6 protocols,
+PF_SYSTEM System domain,
+PF_NDRV Raw access to network device
.Ed
.Pp
The socket has the indicated
.Sh ERRORS
The
.Fn socket
-call fails if:
+system call fails if:
.Bl -tag -width Er
-.It Bq Er EPROTONOSUPPORT
-The protocol type or the specified protocol is not supported
-within this domain.
+.\" ===========
+.It Bq Er EACCES
+Permission to create a socket of the specified type and/or protocol
+is denied.
+.\" ===========
+.It Bq Er EAFNOSUPPORT
+The specified address family is not supported.
+.\" ===========
.It Bq Er EMFILE
The per-process descriptor table is full.
+.\" ===========
.It Bq Er ENFILE
The system file table is full.
-.It Bq Er EACCES
-Permission to create a socket of the specified type and/or protocol
-is denied.
+.\" ===========
.It Bq Er ENOBUFS
Insufficient buffer space is available.
The socket cannot be created until sufficient resources are freed.
+.\" ===========
+.It Bq Er ENOMEM
+Insufficient memory was available to fulfill the request.
+.\" ===========
+.It Bq Er EPROTONOSUPPORT
+The protocol type or the specified protocol is not supported
+within this domain.
+.\" ===========
+.It Bq Er EPROTOTYPE
+The socket type is not supported by the protocol.
.El
+.Pp
+If a new protocol family is defined,
+the socreate process is free to return any desired error code.
+The
+.Fn socket
+system call will pass this error code along
+(even if it is undefined).
+.Sh LEGACY SYNOPSIS
+.Fd #include <sys/types.h>
+.Fd #include <sys/socket.h>
+.Pp
+The include file
+.In sys/types.h
+is necessary.
.Sh SEE ALSO
.Xr accept 2 ,
.Xr bind 2 ,
.Xr connect 2 ,
-.Xr getprotoent 3 ,
.Xr getsockname 2 ,
.Xr getsockopt 2 ,
.Xr ioctl 2 ,
.Xr send 2 ,
.Xr shutdown 2 ,
.Xr socketpair 2 ,
-.Xr write 2
+.Xr write 2 ,
+.Xr getprotoent 3 ,
+.Xr inet 4 ,
+.Xr inet6 4 ,
+.Xr unix 4 ,
+.Xr compat 5
.Rs
.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
.%O "reprinted in UNIX Programmer's Supplementary Documents Volume 1"