Creating a socket (Internet domain)
This section describes the
socket(SSC)
system call and the three most commonly used socket types.
A socket is the basic building block for communication,
providing an endpoint to which a name may be bound.
Sockets function either as clients or servers.
A server typically advertises some service at a well-known
address and waits for clients to request connections.
Clients requiring a particular service attempt to
connect to a server at the server's advertised transport
address.
Sockets are created within a communications domain much
as files are created within a filesystem.
A socket is created with a call to the socket system call:
s = socket (domain, type, protocol)
The call returns a socket descriptor that is used in
system calls operating on the socket.
The domain parameter, also called ``family'',
refers to the protocol family within which communication takes place.
For the Internet address family, the domain is AF_INET.
The socket type is one of:
SOCK_RAW- 
provides access to underlying communications
protocols and are intended for network software developers.
This type is available only to root.
 
SOCK_DGRAM- 
provides unreliable, connectionless transmission
in individually addressed datagrams.
 
SOCK_STREAM- 
provides reliable, full-duplex, connection-oriented
transmission in which data flows through
the socket as a stream of characters.
This is the most commonly used socket type.
 
protocol specifies a particular
protocol to be used with the socket. 
A value of 0 in this field causes
protocol to be selected based on type.
For example, with socket type SOCK_STREAM in address
family AF_INET, protocol is always TCP.
All arguments to the socket routine are integers.
Next topic: 
Address Structures and Routines (Internet domain)
Previous topic: 
Socket Tutorial (Internet domain)
© 2003 Caldera International, Inc.  All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003