Creating a socket (UNIX domain)
Sockets are created with the
socket(SSC)
call:
s = socket(domain, type, protocol);
Where
domain- 
The domain is specified as a manifest constant. For the UNIX domain,
the constant is always AF_UNIX (address
family_UNIX domain).  The manifest constants are named
AF_whatever because they indicate the ``address family'' to use in
interpreting names.
 
type- 
Types are:
SOCK_STREAM
SOCK_DGRAM
 
protocol- 
For UNIX domain sockets, the protocol must be set to 0.
Unlike the Internet domain, the UNIX domain does not allow
a choice of protocols. The system returns a small integer
descriptor, or handle, to use in later system calls which operate
on sockets.  This is equivalent to a file descriptor.  See
open(S).
 
The socket call also requires the <sys/stdio.h>
include file. For example, to create a datagram socket for on-machine use:
   #include <sys/stdio.h>
   
   s = socket(AF_UNIX, SOCK_DGRAM, 0);
Next topic: 
Socket creation errors (UNIX domain)
Previous topic: 
Datagram sockets
© 2003 Caldera International, Inc.  All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003