Buy the book!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
The GNU library includes support for several different kinds of sockets, each with different characteristics. This section describes the supported socket types. The symbolic constants listed here are defined in `sys/socket.h'.
SOCK_STREAMstyle is like a pipe (see section 15. Pipes and FIFOs). It operates over a connection with a particular remote socket and transmits data reliably as a stream of bytes.
Use of this style is covered in detail in 16.9 Using Sockets with Connections.
SOCK_DGRAMstyle is used for sending individually-addressed packets unreliably. It is the diametrical opposite of
Each time you write data to a socket of this kind, that data becomes
one packet. Since
SOCK_DGRAM sockets do not have connections,
you must specify the recipient address with each packet.
The only guarantee that the system makes about your requests to transmit data is that it will try its best to deliver each packet you send. It may succeed with the sixth packet after failing with the fourth and fifth packets; the seventh packet may arrive before the sixth, and may arrive a second time after the sixth.
The typical use for
SOCK_DGRAM is in situations where it is
acceptable to simply re-send a packet if no response is seen in a
reasonable amount of time.
See section 16.10 Datagram Socket Operations, for detailed information about how to use datagram sockets.
|webmaster||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|