[Previous] [Contents] [Index] [Next]

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
bindresvport() Bind a socket to a privileged IP port
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 TCP connection and the hosts 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
gethostbyaddr_r() Get a network host entry, given an Internet address
gethostbyname() Get a network host entry, given a name
gethostbyname_r() Get a network host entry, given a name
gethostent() Read the next line in the host database file
gethostent_r() 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
hstrerror() Get error message string associated with the error return status
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 an Internet address
inet_network() Convert a string into an Internet network number
inet_ntoa() Convert an Internet address into a string
inet_ntoa_r() Convert an Internet address into a string
inet_ntop() Convert a numeric network address to a string
inet_pton() Convert a text host address to a numeric network address
ioctl() Control a device
IP Internet Protocol
isfdtype() Determine whether a file descriptor refers to a socket
listen() Listen for connections on a socket
netent Structure for holding 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 holding 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_querydomain() 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
ROUTE() System packet forwarding database
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 a socket at a specified address
servent Structure for holding 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
sockatmark() Determine whether a socket is at the out-of-band mark
socket() Create an endpoint for communication
socketpair() Create a pair of connected sockets
SOCKSinit() Initialize a connection with a SOCKS server
sysctl() Get or set the system information
TCP Internet Transmission Control Protocol
UDP Internet User Datagram Protocol
UNIX UNIX-domain protocol family
vp_attach() Attach to a Virtual Packet Interface
vp_detach() Detach your application from the stack
vp_getpkt() Get a packet from the stack
vp_ifrname() Return the interface name
vp_ioctl() Send a related virtual packet ioctl command
vp_ktom() Convert a TCP/IP stack address to an application address
vp_mclget() Get a cluster
vp_mfree() Free a single mbuf
vp_mfreem() Free all the mbufs in the chain
vp_mget() Allocate an mbuf
vp_mgethdr() Allocate an mbuf and initialize it as a packet header
vp_mtok() Convert an application address to a TCP/IP stack address
vp_putpkt() Send a packet to the stack
vp_unit() Return the unit number of the given vpid_t

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 TCP connection and the hosts file
hostent Structure that describes an Internet host
gethostbyaddr() Get a network host entry, given an Internet address
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
gethostent_r() 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
inet_ntoa_r() Convert an Internet address into a string
inet_ntop() Convert a numeric network address to a string
inet_pton() Convert a text host address to a numeric network address

Miscellaneous

Item Summary
herror() Print the message associated with the value of h_errno to standard error
hstrerror() Get error message string associated with the error return status
ioctl() Control a device
sysctl() Get or set the system information

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 holding 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 holding 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 holding information from the network services database
setservent() Open the network services database file

Protocols

Item Summary
ICMP Internet Control Message Protocol
IP Internet Protocol
ROUTE System packet forwarding database
TCP Internet Transmission Control Protocol
UDP Internet User Datagram Protocol
UNIX UNIX-domain protocol family

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_querydomain() 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
bindresvport() Bind a socket to a privileged IP port (Unix)
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
isfdtype() Determine whether a file descriptor refers to 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
sockatmark() Determine whether a socket is at the out-of-band mark
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

Virtual Packet

Item Summary
vp_attach() Attach to a Virtual Packet Interface
vp_detach() Detach your application from the stack
vp_getpkt() Get a packet from the stack
vp_ifrname() Return the interface name
vp_ioctl() Send a related virtual packet ioctl command
vp_ktom() Convert a TCP/IP stack address to an application address
vp_mclget() Get a cluster
vp_mfree() Free a single mbuf
vp_mfreem() Free all the mbufs in the chain
vp_mget() Allocate an mbuf
vp_mgethdr() Allocate an mbuf and initialize it as a packet header
vp_mtok() Convert an application address to a TCP/IP stack address
vp_putpkt() Send a packet to the stack
vp_unit() Return the unit number of the given vpid_t

What's in a function description?

Each function page consists of a number of subsections:

Synopsis:

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:

A description of the function or macro.

Returns:

The return value (if any) for the function or macro.

Errors:

Describes the possible values that the function might assign to the global variable errno.

Examples:

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

Classification:

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

POSIX 1003.1g (Draft: Protocol Independent Interfaces)
These functions are specified in the document Information Technology - Portable Operating System Interface (POSIX) Part 1g: Protocol Independent Interfaces (PII). This draft document defines a programmatic interface for network process-to-process communication, such that the application may be independent of the underlying protocols. Note that it's a draft document and is subject to change.
QNX 4
These functions or macros are neither ANSI nor POSIX. They perform a function related to QNX 4. They may be found in other implementations of C for personal computers with QNX 4. Use these functions with caution if portability is a consideration.
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.
SOCKS
These functions are part of the SOCKS package consisting of a proxy server, client programs (rftp and rtelnet), and a library (libsocks.a) for adapting other applications into new client programs. For more information, see the appendix SOCKS - A Basic Firewall.
UNIX
These functions exist on some UNIX systems, but are outside of the POSIX or ANSI standards.

We've created the following Unix categories to differentiate:

Legacy Unix
Functions included for backwards compatibility only. New applications shouldn't implement these functions.
Standard Unix
Functions that match XOPEN specifications.
Unix
Unix functions that don't fall into the above two categories. ;-)

Function safety:

Indicates whether or not it's safe to use the TCP/IP function in:

Interrupt handler
An interrupt-safe function behaves as documented even if used in an interrupt handler. Functions flagged as interrupt-unsafe shouldn't be used in interrupt handlers.
Signal handler
A signal-safe function behaves as documented even if called from a signal handler even if the signal interrupts a signal-unsafe function.

Some of the signal-safe functions modify errno on failure. If you use any of these in a signal handler, asynchronous signals may have the side effect of modifying errno in an unpredictable way. If any of the code that can be interrupted checks the value of errno (this also applies to library calls, so you should assume that most library calls may internally check errno), make sure that your signal handler saves errno on entry and restores it on exit.

All of the above also applies to signal-unsafe functions, with one exception: if a signal handler calls a signal-unsafe function, make sure that signal doesn't interrupt a signal-unsafe function.

Thread
A thread-safe function behaves as documented even if called in a multi-threaded environment.
Note: The "safety" designations documented in this manual are valid for the the TCP/IP 5.0 release and could change in future versions.

Caveats:

Gives warnings about the function.

See also:

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


[Previous] [Contents] [Index] [Next]