TCP/IP Libraries

This chapter contains descriptions of the TCP/IP library functions, data structures, and protocols, all arranged in alphabetical order.

We've also provided summary lists of all the entries:

There's also a discussion of what you'll find in a function description.

Alphabetical list of entries

Item Summary
accept() Accept a connection on a socket
bind() Bind a name to a socket
connect() Initiate a connection on a socket
dn_comp() Compress an Internet domain name
dn_expand() Expand a compressed Internet domain name
ds_clear() Delete a data server variable
ds_create() Create a data server variable
ds_deregister() Deregister an application with the data server
ds_flags() Set the flags for a data server variable
ds_get() Retrieve a data server variable
ds_register() Register an application with the data server
ds_set() Set a data server variable
endhostent() Close the host database file
endnetent() Close the network name database file
endprotoent() Close the protocol name database file
endservent() Close the network services database file
gethostbyaddr() Get a network host entry, given an Internet address
gethostbyname() Get a network host entry, given a name
gethostent() Read the next line in the host database file
gethostname() Get the name of the current host
getnetbyaddr() Get a network entry, given an address
getnetbyname() Get a network entry, given a name
getnetent() Read the next line of the network name database file
getpeername() Get the name of the peer connected to a socket
getprotobyname() Get a protocol entry, given a name
getprotobynumber() Get a protocol entry, given a number
getprotoent() Read the next line of the protocol name database file
getservbyname() Get a service entry, given a name
getservbyport() Get a service entry, given a port
getservent() Read the next line of the network services database file
getsockname() Get the name of a socket
getsockopt() Get options associated with a socket
herror() Print the message associated with the value of h_errno to standard error
hostent Structure that describes an Internet host
htonl() Convert a 32-bit value from host byte order to network byte order
htons() Convert a 16-bit value from host byte order to network byte order
ICMP Internet Control Message Protocol
inet_addr() Convert a string into a numeric Internet address
inet_aton() Convert a string into an Internet address stored in a structure
inet_lnaof() Extract the local network address from an Internet address
inet_makeaddr() Convert a network number and a local network address into an Internet address
inet_netof() Extract the network number from and Internet address
inet_network() Convert a string into an Internet network number
inet_ntoa() Convert an Internet address into a string
ioctl() Control a device
IP Internet Protocol
listen() Listen for connections on a socket
netent Structure for information from the network database
ntohl() Convert a 32-bit value from network byte order to host byte order
ntohs() Convert a 16-bit value from network byte order to host byte order
protoent Structure for information from the protocol database
Raccept() Accept a connection on a socket via a SOCKS server
Rbind() Bind a name to a socket via a SOCKS server
rcmd() Execute a command on a remote host
Rconnect() Initiate a connection on a socket via a SOCKS server
read_main_config_file() Read the snmpd.conf file
recv() Receive a message from a socket
recvfrom() Receive a message from the socket at a specified address
recvmsg() Receive a message and its header from a socket
res_init() Initialize the Internet domain name resolver routines
res_mkquery() Construct an Internet domain name query
res_query() Query the local Internet domain name server
res_search() Query a local server, using search options
res_send() Send a preformatted Internet domain name query
Rgetsockname() Get the name of a socket via a SOCKS server
Rlisten() Listen for connections on a socket via a SOCKS server
Rrcmd() Execute a command on a remote host via a SOCKS server
rresvport() Obtain a socket with a privileged address
Rselect() Check for descriptions that are ready for reading or writing via a SOCKS server
ruserok() Check the identity of a remote host
send() Send a message to a connected socket
sendmsg() Send a message and its header to a socket
sendto() Send a message to the socket at a specified address
servent Structure for information from the network services database
sethostent() Open the host database file
sethostname() Set the name of the current host
setnetent() Open the network name database file
setprotoent() Open the protocol name database file
setservent() Open the network services database file
setsockopt() Set options associated with a socket
shutdown() Shut down part of a full-duplex connection
snmp_close() Close an SNMP session
snmp_free_pdu() Free an SNMP message structure
snmp_open() Open an SNMP session
snmp_pdu Structure that describes an SNMP transaction
snmp_pdu_create() Create an SNMP message structure
snmp_read() Read an SNMP message
snmp_select_info() Position to a block within an SNMP message structure
snmp_send() Send SNMP messages
snmp_session Structure that defines a set of transactions with similar transport characteristics
snmp_timeout() Timeout during an SNMP session
socket() Create an endpoint for communication
socketpair() Create a pair of connected sockets
SOCKSinit() Initialize a connection with a SOCKS server
TCP Internet Transmission Control Protocol
UDP Internet User Datagram Protocol

Entries by category

In this chapter, you'll notice that many functions are related to other functions. This section arranges the functions into the following categories:

Current host

Item Summary
gethostname() Get the name of the current host
sethostname() Set the name of the current host

Data server

Item Summary
ds_clear() Delete a data server variable
ds_create() Create a data server variable
ds_deregister() Deregister an application with the data server
ds_flags() Set the flags for a data server variable
ds_get() Retrieve a data server variable
ds_register() Register an application with the data server
ds_set() Set a data server variable

Host database

Item Summary
endhostent() Close the host database file
hostent Structure that describes an Internet host
gethostbyaddr() Get a network host entry, given an Internet address
gethostbyname() Get a network host entry, given a name
gethostent() Read the next line in the host database file
htonl() Convert a 32-bit value from host byte order to network byte order
htons() Convert a 16-bit value from host byte order to network byte order
ntohl() Convert a 32-bit value from network byte order to host byte order
ntohs() Convert a 16-bit value from network byte order to host byte order
sethostent() Open the host database file

Internet address manipulation

Item Summary
inet_addr() Convert a string into a numeric Internet address
inet_aton() Convert a string into an Internet address stored in a structure
inet_lnaof() Extract the local network address from an Internet address
inet_makeaddr() Convert a network number and a local network address into an Internet address
inet_netof() Extract the network number from and Internet address
inet_network() Convert a string into an Internet network number
inet_ntoa() Convert an Internet address into a string

Miscellaneous

Item Summary
herror() Print the message associated with the value of h_errno to standard error
ioctl() Control a device

Network database

Item Summary
endnetent() Close network name database file
getnetbyaddr() Get network entry, given an address
getnetbyname() Get network entry, given a name
getnetent() Read the next line of the network name database file
netent Structure for information from the network database
setnetent() Open the network name database file

Network protocol database

Item Summary
endprotoent() Close the protocol name database file
getprotobyname() Get a protocol entry, given a name
getprotobynumber() Get a protocol entry, given a number
getprotoent() Read the next line of the protocol name database file
protoent Structure for information from the protocol database
setprotoent() Open the protocol name database file

Network services database

Item Summary
endservent() Close network services database file
getservbyname() Get a service entry, given a name
getservbyport() Get a service entry, given a port
getservent() Read the next line of the network services database file
servent Structure for information from the network services database
setservent() Open the network services database file

Protocols

Item Summary
ICMP Internet Control Message Protocol
IP Internet Protocol
TCP Internet Transmission Control Protocol
UDP Internet User Datagram Protocol

Remote hosts

Item Summary
rcmd() Execute a command on a remote host
rresvport() Obtain a socket with a privileged address
ruserok() Check the identity of a remote host

Resolver

Item Summary
dn_comp() Compress an Internet domain name
dn_expand() Expand a compressed Internet domain name
res_init() Initialize the Internet domain name resolver routines
res_mkquery() Construct an Internet domain name query
res_query() Query the local Internet domain name server
res_search() Query a local server, using search options
res_send() Send a preformatted Internet domain name query

SNMP messages

Item Summary
read_main_config_file() Read the snmpd.conf file
snmp_close() Close an SNMP session
snmp_free_pdu() Free an SNMP message structure
snmp_open() Open an SNMP session
snmp_pdu Structure that describes an SNMP transaction
snmp_pdu_create() Create an SNMP message structure
snmp_read() Read an SNMP message
snmp_select_info() Position to a block within an SNMP message structure
snmp_send() Send SNMP messages
snmp_session Structure that defines a set of transactions with similar transport characteristics
snmp_timeout() Timeout during an SNMP session

Sockets

Item Summary
accept() Accept a connection on a socket
bind() Bind a name to a socket
connect() Initiate a connection on a socket
getpeername() Get the name of the peer connected to a socket
getsockname() Get the name of a socket
getsockopt() Get options associated with a socket
listen() Listen for connections on a socket
setsockopt() Set options associated with a socket
shutdown() Shut down part of a full-duplex connection
socket() Create an endpoint for communication
socketpair() Create a pair of connected sockets

Socket messages

Item Summary
recv() Receive a message from a socket
recvfrom() Receive a message from the socket at a specified address
recvmsg() Receive a message and its header from a socket
send() Send a message to a connected socket
sendmsg() Send a message and its header to a socket
sendto() Send a message to the socket at a specified address

SOCKS server

Item Summary
Raccept() Accept a connection on a socket via a SOCKS server
Rbind() Bind a name to a socket via a SOCKS server
Rconnect() Initiate a connection on a socket via a SOCKS server
Rgetsockname() Get the name of a socket via a SOCKS server
Rlisten() Listen for connections on a socket via a SOCKS server
Rrcmd() Execute a command on a remote host via a SOCKS server
Rselect() Check for descriptions that are ready for reading or writing via a SOCKS server
SOCKSinit() Initialize a connection with a SOCKS server

What's in a function description?

Each function page consists of a number of subsections:

Synopsis:

This subsection gives the header files that should be included within a source file that references the function or macro. It also shows an appropriate declaration for the function or for a function that could be substituted for a macro. This declaration isn't included in your program; only the header file(s) should be included.

When a pointer argument is passed to a function, and that function doesn't modify the item indicated by that pointer, then the argument is shown with const before the argument. For example, the following indicates that the array pointed at by string isn't changed:

    const char *string

Description:

This subsection is a description of the function or macro.

Returns:

This subsection describes the return value (if any) for the function or macro.

Errors:

This subsection describes the possible values that the function might assign to the global variable errno.

Examples:

This optional subsection consists of one or more examples of the use of the function. The examples are often just fragments of code (not complete programs) for illustrative purposes.

Classification:

This subsection provides an indication of where the function or macro is commonly found. The following notation is used:

POSIX 1003.1g (draft)
These functions are specified in the document Information Technology - Portable Operating System Interface (POSIX) Part 1g: Protocol Independent Interfaces (PII). This draft document describes networking interfaces. Note that it's a draft document and is subject to change.
SOCKS
A generic firewall package.
SNMP
Simple Network Management Protocol is a network-management protocol whose base document is RFC 1067. It's used to query and modify network device states.
UNIX
These functions exist on some UNIX systems, but are outside of the POSIX or ANSI standards.

The Classification section also indicates whether or not it's safe to use the function:

Caveats:

This optional subsection gives warnings about the function.

See also:

This optional subsection provides a list of related functions or macros, or places to look for more information.