Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

UNIX Network Programming: Sockets Introduction

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
This sample chapter describes the sockets API with a discussion of socket address structures.

This chapter begins the description of the sockets API. We begin with socket address structures, which will be found in almost every example in the text. These structures can be passed in two directions: from the process to the kernel, and from the kernel to the process. The latter case is an example of a value-result argument, and we will encounter other examples of these arguments throughout the text.

The address conversion functions convert between a text representation of an address and the binary value that goes into a socket address structure. Most existing IPv4 code uses inet_addr and inet_ntoa, but two new functions, inet_pton and inet_ntop, handle both IPv4 and IPv6.

One problem with these address conversion functions is that they are dependent on the type of address being converted: IPv4 or IPv6. We will develop a set of functions whose names begin with sock_ that work with socket address structures in a protocol-independent fashion. We will use these throughout the text to make our code protocol-independent.

  • Share ThisShare This
  • Save To Your Account

Discussions

comments powered by Disqus

Related Resources

What Apple and Every Apple Support Professional Must Do
By on April 14, 2012Comments

The Flashback attack is a sign of more to come.  Are you prepared to see your Apple computer (or those you support) as functional UNIX devices that require special skills?


Flashbacks On Your Mac?
By on April 9, 2012Comments
Unless you live under a rock, by now, you should have learned about the Flashback trojan that has compromised over 600,000 Apple computers.

Care to learn what you can do?  Read on...


Commodities
By on March 7, 2012Comments

What are the security implications of Operating Systems being reduced to container commodities that live to give applications life support?


See All Related Blogs