Guidelines for Using Socket Types
If you are communicating with an existing application, you must use the
same socket type and the same protocol as the existing application.
Raw sockets have a special purpose of interfacing directly to the underlying
protocol layer. If you are writing a new protocol on top of Internet Protocol
(IP) or wish to use the Internet Control Message Protocol (ICMP), then you
must use raw sockets.
You should consider the following factors in choosing a socket type for
new applications:
- Reliability: Stream and sequenced packet sockets
provide the most reliable connection. Connectionless datagram and raw sockets
are unreliable because packets can be discarded, duplicated, or received
out of order. This may be acceptable if the application does not require
reliability, or if the application implements the reliability on top of
the sockets API.
- Performance: The overhead associated with reliability,
flow control, packet reassembly, and connection maintenance degrades the
performance of stream and sequenced packet sockets so that these socket
types do not perform as well as datagram sockets acting in a connectionless
mode.
- Amount of data to be transferred: Datagram and sequenced
packet sockets impose a limit on the amount of data transferred in each
packet.
[Back: Socket Types Summary]
[Next: Socket Creation]