Socket Functions

The following table shows the socket functions with a description of the purpose of each.

Programming element Description
accept (Windows Sockets) This function permits an incoming connection attempt on a socket.
bind (Windows Sockets) This function associates a local address with a socket.
closesocket This function closes an existing socket.
connect (Windows Sockets) This function establishes a connection to a specified socket.
freeaddrinfo This function frees address information that the getaddrinfo function dynamically allocates in its addrinfo structures.
getaddrinfo This function provides protocol-independent translation from host name to address.
gethostbyaddr This function retrieves the host information corresponding to a network address.
gethostbyname This function retrieves host information corresponding to a host name from a host database.
gethostname This function returns the standard host name for the local machine.
getnameinfo This function provides name resolution from an address to the host name.
getpeername (Windows Sockets) This function retrieves the name of the peer to which a socket is connected.
getsockname (Windows Sockets) This function retrieves the local name for a socket.
getsockopt (Windows Sockets) This function retrieves a socket option.
htonl This function converts a u_long from host to TCP/IP network byte order, which is big-endian.
htons This function converts a u_short from host to TCP/IP network byte order, which is big-endian.
inet_addr This function converts a string containing an (Ipv4) Internet Protocol dotted address into a proper address for the in_addr structure.
inet_ntoa This function converts an (Ipv4) Internet network address into a string in Internet standard dotted format.
ioctlsocket This function controls the I/O mode of a socket.
listen This function places a socket at a state where it is listening for an incoming connection.
ntohl This function converts a u_long from TCP/IP network order to host byte order, which is little-endian on Intel processors.
ntohs This function converts a u_short from TCP/IP network byte order to host byte order, which is little-endian on Intel processors.
recv This function receives data from a connected socket.
recvfrom This function receives a datagram and stores the source address.
select This function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O.
send This function sends data on a connected socket.
sendto This function sends data to a specific destination.
sethostname This function is used to register the host name on a network with the Windows Internet Naming Service (WINS).
setsockopt (Windows Sockets) This function sets a socket option.
shutdown This function disables sends or receives on a socket.
socket (Windows Sockets) This function creates a socket that is bound to a specific service provider.

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.