• Datagram sockets ( SOCK_DGRAM ): These types of sockets use User Datagram
Protocol (UDP). These sockets are known as connectionless sockets. It should
be noted that they are unreliable and the data may arrive out of sequence.
There may be duplication as well. A sample usage would be socket(PF_
INET, SOCK_DGRAM, 0); .
• Raw sockets ( SOCK_RAW ): These types of socket neither use TCP nor UDP.
It directly communicates with the IP layer. This may be useful to build
a new protocol and is a lower-level approach.
The network layer
Our main concern is the SOCK_STREAM type of sockets. These types of sockets
are unduplicated and have a best-effort policy to guarantee in-order delivery
of datagrams to have a full reconstruction of the stream on the receiving side.
What we can do with these sockets is very simple:
• Create a connection with connect
• Use read and write or send and recv to transmit data respectively
• Close the connection with close