Friday, August 5, 2011

Socket Types and Protocols

Before starting I will recommend to follow my previous post on the sockets. In this post we will be primarily focusing on the socket(2) function call. This includes expanding upon the following:

The domain argument
The socket type argument
The protocol argument

There is always a choice of confusion between choosing the various socket types to be used. I will present the following four major types:

Socket Domain and Type Summary

This section has been provided to allow you to review in summary form what you have learned in this chapter. Figure below illustrates the relationship that exists between the three socket(2) function arguments.

You'll notice that the domain argument appears on the left of Figure. The domain argument is the first argument of the socket(2) and socketpair(2) functions. It is also the least specific of the three values. The domain argument chooses a family of protocols that you want to work with. The second argument defines the socket type. Choosing the socket type eliminates a number of variations within the specified protocol family. Looking at Figure, you can see that choosing
SOCK_DGRAM excludes protocols that stem from SOCK_STREAM above it.

This diagram summarizes socket(2) parameter relationships.
Finally, on the very right, Figure above provides a sampling of the protocol choices that are available in the socket(2) function call. This parameter finalizes the protocol to be used.

No comments:

Post a Comment