Chapter 4: Advanced Sockets Functions

 < Day Day Up > 



Overview

In this chapter, we continue looking at the details of the Sockets API, in this case some advanced functions and some other functions whose usage is rare. This discussion, as in the prior chapter, is based on the Linux API. The prototypes and usage apply to other implementations as well. The Sockets functions that are discussed in this chapter are shown in Table 4.1. All code for this chapter can be found on the companion CD-ROM under /software/ch4.

Table 4.1: SOCKETS FUNCTIONS DISCUSSED IN CHAPTER 4

Function

Description

select

Provides event notification of socket events

getsockname

Returns the address of the local socket

getpeername

Returns the address of the remote socket

getsockopt

Returns the value of a socket option for a given socket

setsockopt

Manipulates a socket option for a given socket

shutdown

Closes a socket with more control

gethostname

Retrieves the name of the host on which this stack operates

sethostname

Sets the name of the host on which this stack operates

gethostbyaddr

Returns the FQDN for a given IP address

gethostbyname

Returns the IP address for a given FQDN

getservbyname

Returns the port number for a given service string

getservbyport

Returns the service string for a given port number

The following subsections illustrate the API calls, and discuss any special characteristics of their application and common problems that are associated in their use.



 < Day Day Up > 



BSD Sockets Programming from a Multi-Language Perspective
Network Programming for Microsoft Windows , Second Edition (Microsoft Programming Series)
ISBN: 1584502681
EAN: 2147483647
Year: 2003
Pages: 225
Authors: Jim Ohlund

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net