These functions are used by the user process to send or receive packets and
to do other socket operations. For more information see their respective
manual pages.
socket (2)
creates a socket,
connect (2)
connects a socket to a remote socket address,
the
bind (2)
function binds a socket to a local socket address,
listen (2)
tells the socket that new connections shall be accepted, and
accept (2)
is used to get a new socket with a new incomming connection.
socketpair (2)
returns two connected anonymous sockets (only implemented for a few
local families like
PF_UNIX )
send (2),
sendto (2),
and
sendmsg (2)
send data over a socket, and
recv (2),
recvfrom (2),
recvmsg (2)
receive data from a socket.
poll (2)
and
select (2)
wait for arriving data or a readiness to send data.
In addition, the standard I/O operations like
write (2),
writev (2),
sendfile (2),
read (2),
and
readv (2)
can be used to read and write data.
getsockname (2)
returns the local socket address and
getpeername (2)
returns the remote socket address.
getsockopt (2)
and
setsockopt (2)
are used to set or get socket layer or protocol options.
ioctl (2)
can be used to set or read some other options.
close (2)
is used to close a socket.
shutdown (2)
closes parts of a full duplex socket connection.
Seeking, or calling
pread (2)
or
pwrite (2)
with a non-zero position is not supported on sockets.
It is possible to do non-blocking IO on sockets by setting the
O_NONBLOCK
flag on a socket file descriptor using
fcntl (2).
O_NONBLOCK
is inherited through an accept.
Then all operations that would normally block will (usually)
return with
EAGAIN ;
connect (2)
returns an
EINPROGRESS
error in this case.
The user can then wait for various events via
poll (2)
or
select (2).