中文网站
  Advanced Search
Read the latest Blogs from IT professionals in the field. Read and write community created documents. Need IT help? Ask our staff. Connect with your peers. Check our Tech Shop for posters, books and software tools. Home

11.1.3.1 The basic function for creating sockets(1)

We already said that the basic function for creating sockets and working with them are identical for all supported address families. In a C program, an IPv6/TCP socket can be created in the usual way:

To make the long story short, all basic socket functions remain unchanged. Here is an alphabetical list with short descriptions (see the on-line manual pages for details):

bind()

Bind the socket to a local address.

close()

Close the socket.

connect()

Connect to a remote host.

getpeername()

Obtain the address of the remote end.

getsockopt()

Get the socket options.

listen()

Listen on the socket (wait for a connection request).

recv()

Read data from the connected socket. address.

recvfrom()

Read data from a specified source (mainly used with UDP sockets).

send()

Send data to a connected socket.

sendto()

Send data to a specified destination (mainly used with UDP sockets).

setsockopt()

Set socket options.

shutdown()

Terminate the communication in one or both directions.