Creating and Binding Sockets
A socket is created with the socket() call. This call creates a socket of
a specified:
- protocol family
- socket type
- protocol
Sockets have different qualities depending on these specifications.
The protocol family specifies the protocol stack to be used with
the created socket. The socket type defines its communication properties
such as reliability, ordering, and prevention of duplication of messages
(see Socket Types). The protocol
specifies which network protocol to use within the domain. The protocol
must support the characteristics requested by the socket type.
An application can use the bind() call to associate a local name (usually
a network address) with a socket. The form and meaning of socket addresses
are dependent on the protocol family in which the socket is created. The
socket name is specified by a sockaddr structure.
The bind() call is optional under some circumstances:
the connect() call and any of the data
transmission calls (for example, send())
will automatically associate the local name to the socket if bind() hasn't
been called.
[Back: Socket Facilities]
[Next: Accepting and Initiating Socket Connections]