socket(7) —
NAME
socket − Berkeley socket emulation under System V STREAMS
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
s = socket (AF_INET, type, protocol);
or
#include <sys/sohdr.h>
s = open (device, O_RDWR, 0);
ioctl (s, I_PUSH, "socket");
DESCRIPTION
Berkeley sockets are emulated by the socket STREAMS module and the user library libinet.a. The module and library communicate, using a socket protocol that is defined in <sys/sohdr.h>. All state information about the open socket is stored in the socket module, so extra system calls can be avoided. The state is unaffected by forks.
The Berkeley system calls emulated by the library are:
SOCKET
Open the appropriate STREAMS device and push the socket module on the stream.
BIND Bind a name to the socket.
CONNECT
Initiate a connection to a foreign address.
LISTEN
Listen for connections on the socket.
ACCEPT
Accept a connection on a listening socket.
SEND, SENDTO, SENDMSG
Send a message to a foreign address.
RECV, RECVFROM, RECVMSG
Receive a message from a foreign address.
SETSOCKOPT, GETSOCKOPT
Set or retrieve socket option values.
GETSOCKNAME
Get the name bound to the socket.
GETPEERNAME
Get the peer name connected to the socket.
SHUTDOWN
Shut down part of the socket connection.
SELECT
Emulate the synchronous I/O multiplexing using the poll system call.
The read and write system calls are converted by the socket module into the Transport Layer Interface (TLI) required by lower-level protocols.
The direct interface to the socket module consists of the user-originated primitives SO_SOCKET, SO_BIND, SO_CONNECT, SO_LISTEN, SO_ACCEPT, SO_FDINSERT, SO_SEND, SO_SETOPT, SO_GETOPT, SO_GETNAME, SO_GETPEER and SO_SHUTDOWN and the module-originated primitives SO_ACCEPT_ACK, SO_UNITDATA_IND, SO_GETOPT_ACK, SO_GETNAME_ACK, SO_GETPEER_ACK, SO_ERROR_ACK, and SO_OK_ACK.
The current implementation of the socket module is limited to the AF_INET domain and the SOCK_STREAM, SOCK_DGRAM, and SOCK_RAW types. EPROTO will be returned, corresponding to the TLI error TOUTSTATE.
SEE ALSO
accept(3I), bind(3I), connect(3I), getpeername(3I), getsockname(3I), getsockopt(3I), listen(3I), recv(3I), select(3I), send(3I), shutdown(3I), socket(3I), ip(7), tcp(7), udp(7).
An Introductory 4.3BSD Interprocess Communication Tutorial, Stuart Sechrest, University of California, Berkeley.
An Advanced 4.3BSD Interprocess Communication Tutorial, Samuel J. Leffler, et.al., University of California, Berkeley.
“Transport Layer Interface,” Network Programmer’s Guide, UNIX System V Release 3.
DIAGNOSTICS
Most of the failures reported by the socket module will be specific to one of the Berkeley system calls emulated, so the appropriate manual page for the library function should be consulted. If library functions are called in the wrong order or if error indications are ignored and calls proceed after an error, the error EPROTO will be returned, corresponding to the TLI error TOUTSTATE.
\*U — Version 1.0