Windows Sockets API Function Overview

Socket Functions

accept()

An incoming connection is acknowledged and associated with an immediately created socket. The original socket is returned to the listening state.

bind()

Assign a local name to an unnamed socket.

closesocket()

Remove a socket descriptor from the per-process object reference table. Only blocks if SO_LINGER is set.

connect()

Initiate a connection on the specified socket.

getpeername()

Retrieve the name of the peer connected to the specified socket descriptor.

getsockname()

Retrieve the current name for the specified socket.

getsockopt()

Retrieve options associated with the specified socket descriptor.

htonl()

Convert a 32-bit quantity from host byte order to network byte order.

htons()

Convert a 16-bit quantity from host byte order to network byte order.

inet_addr()

Converts a character string representing a number in the Internet standard ".'' notation to an Internet address value.

inet_ntoa()

Converts an Internet address value to an ASCII string in ".'' notation i.e. "a.b.c.d''.

ioctlsocket()

Provide control for descriptors.

listen()

Listen for incoming connections on a specified socket.

ntohl()

Convert a 32-bit quantity from network byte order to host byte order.

ntohs()

Convert a 16-bit quantity from network byte order to host byte order.

recv()*

Receive data from a connected socket.

recvfrom()*

Receive data from either a connected or unconnected socket.

select()*

Perform synchronous I/O multiplexing.

send()*

Send data to a connected socket.

sendto()*

Send data to either a connected or unconnected socket.

setsockopt()

Store options associated with the specified socket descriptor.

shutdown()

Shut down part of a full-duplex connection.

socket()

Create an endpoint for communication and return a socket descriptor.


*These functions may block if acting on a blocking socket

Database Functions

gethostbyaddr()*

Retrieve the name(s) and address corresponding to a network address.

gethostname()

Retrieve the name of the local host.

gethostbyname()*

Retrieve the name(s) and address corresponding to a host name.

getprotobyname()*

Retrieve the protocol name and number corresponding to a protocol name.

getprotobynumber()*

Retrieve the protocol name and number corresponding to a protocol number.

getservbyname()*

Retrieve the service name and port corresponding to a service name.

getservbyport()*

Retrieve the service name and port corresponding to a port.


*These functions may block if acting on a blocking socket

Windows Sockets Asynchronous Extensions

WSAAsyncGetHostByAddr()
WSAAsyncGetHostByName()
WSAAsyncGetProtoByName()
WSAAsyncGetProtoByNumber()
WSAAsyncGetServByName()
WSAAsyncGetServByPort()

A set of functions which provide asynchronous versions of the standard Berkeley getXbyY() functions. For example, the WSAAsyncGetHostByName() function provides an asynchronous message based implementation of the standard Berkeley gethostbyname() function.

WSAAsyncSelect()

Perform asynchronous version of select().

WSACancelAsyncRequest()

Cancel an outstanding instance of a WSAAsyncGetXByY() function.

WSACancelBlockingCall()

Cancel an outstanding "blocking" API call.

WSACleanup()

Sign off from the underlying Windows Sockets DLL.

WSAGetLastError()

Obtain details of last Windows Sockets API error

WSAIsBlocking()

Determine if the underlying Windows Sockets DLL is already blocking an existing call for this thread.

WSASetBlockingHook()

"Hook" the blocking method used by the underlying Windows Sockets implementation.

WSASetLastError()

Set the error to be returned by a subsequent WSAGetLastError().

WSAStartup()

Initialize the underlying Windows Sockets DLL.

WSAUnhookBlockingHook()

Restore the original blocking function.