HPlogo HP 9000 Networking: BSD Sockets Interface Programmer's Guide > Chapter 8 Programming Hints

Summary Tables for System and Library Calls

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

The following table contains a summary of the BSD Sockets system calls.

Table 8-1 BSD Sockets System Calls

System Call

Description

socket

Creates a socket, or communication endpoint for the calling process.

bind

Assigns a socket address to the socket specified by the calling process.

listen

Sets up a queue for incoming connection requests. (Stream sockets only.)

connect

For stream sockets, requests and creates a connection between the remote socket (specified by address) and the socket (specified by descriptor) of the calling process. For datagram sockets, permanently specifies the remote peer socket.

accept

Receives a connection between the socket of the calling process and the socket specified in the associated connect call. (Stream sockets only.)

send, sendto, sendmsg

Sends data from the specified socket.

recv, recvfrom, recvmsg

Receives data at the specified socket.

shutdown

Disconnects the specified socket.

getsockname

Gets the socket address of the specified socket.

getsockopt, setsockopt

Gets, or sets, the options associated with a socket.

getpeername

Gets the name of the peer socket connected to the specified socket.

 

The following table contains a summary of the other system calls that can be used with BSD Sockets.

Table 8-2 Other BSD Sockets System Calls

System Call

Description

read

Can be used to read data at stream or datagram sockets just like recv or recvfrom , without the benefit of the recv flags. Read offers implementation independence; the descriptor can be for a file, a socket or any other object.

write

Can be used to write data from stream sockets (and datagram sockets if you declare a default remote socket address) just like send. Write offers implementation independence; the descriptor can be for a file, a socket or any other object.

close

Deallocates socket descriptors. The last close can be used to destroy a socket. Close does a graceful disconnect or a hard close, depending on the LINGER option. Refer to the sections on "Closing a Socket."

select

Can be used to improve efficiency for a process that accesses multiple sockets or other I/O devices simultaneously. Refer to the sections on "Synchronous I/O Multiplexing with Select."

ioctl

Can be used for finding the number of receivable bytes with FIONREAD and for setting the nonblocking I/O flag with FIOSBNBIO. Can also be used for setting a socket to receive asynchronous signals with FIOASYNC .

fcntl

Can be used for duplicating a socket descriptor and for setting the O_NDELAY or O_NONBLOCK flag.

 

BSD Sockets attempts to isolate host-specific information from applications by providing library calls that return the necessary information.

The following table contains a summary of the library calls used with BSD Sockets. The library calls are in the common "c" library named libc.sl. Therefore, there is no need to specify any library name on the cc command line to use these library calls, libc.sl is used automatically.

Table 8-3 Library Calls

Library Call

Description

inet_addr

inet_lnaof

inet_makeaddr

inet_netof

inet_network

internet address manipulation routines

setservent

endservent

getservbyname

getservbyport

getservent

get or set service entry

setprotoent

endprotoent

getprotobyname

getprotobynumber

getprotoent

get or set protocol entry

setnetent

endnetent

getnetbyaddr

getnetbyname

getnetent

get or set network entry

sethostent

endhostent

gethostbyaddr

gethostbyname

gethostent

get or set host entry

 

© 1997 Hewlett-Packard Development Company, L.P.