Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What is the difference between sock_seqpacket sockets and sock_stream sockets?


Asked by Cedric Dudley on Dec 12, 2021 FAQ



SOCK_SEQPACKET sockets employ the same system calls as SOCK_STREAM sockets. The only difference is that read (2) calls will return only the amount of data requested, and any data remaining in the arriving packet will be discarded.
Also Know,
The SOCK_SEQPACKET socket type is similar to the SOCK_STREAM type, and is also connection-oriented. The only difference between these types is that record boundaries are maintained using the SOCK_SEQPACKET type.
Keeping this in consideration, The socket has the indicated type, which specifies the communication semantics. Currently defined types are: Provides sequenced, reliable, two-way, connection-based byte streams. An out-of-band data transmission mechanism may be supported.
Indeed,
A stream socket must be in a connected state before any data may be sent or received on it. A connection to another socket is created with a connect (2) call. Once connected, data may be transferred using read (2) and write (2) calls or some variant of the send (2) and recv (2) calls.
Furthermore,
In one line, SOCK_STREAM is for connection oriented sockets, where the underlying OS creates and manages the headers for L4 (TCP), L3 and L2. OTOH SOCK_RAW provides more fine-grained control over header and packet construction, where the user has to construct and supply the headers and can also manage the contents.