Winsock Functions
This section provides reference information for the Windows Sockets API (Winsock) functions. Winsock is a Microsoft implementation of the Berkeley sockets API, providing a network programming interface for Windows.
Core Networking Functions
socket
Creates a socket that is bound to a specific transport service provider.
bind
Associates a local protocol information structure with a socket.
connect
Establishes a connection to a specified remote socket.
listen
Puts a socket into a listening state for incoming connection requests.
accept
Permits an incoming connection on a socket.
send
Sends data on a connected socket.
recv
Receives data from a connected socket or bound-to-connection socket.
closesocket
Closes an existing socket.
Address Information Functions
getaddrinfo
Translates a network address structure to a human-readable representation.
freeaddrinfo
Frees address information returned by the getaddrinfo function.
Error Handling Functions
WSAGetLastError
Retrieves the error code for the last Windows Sockets operation that failed.
WSASetLastError
Sets the last error for the calling thread.
Helper Functions
ntohs
Converts a 16-bit quantity from network byte order to host byte order.
htons
Converts a 16-bit quantity from host byte order to network byte order.
ntohl
Converts a 32-bit quantity from network byte order to host byte order.
htonl
Converts a 32-bit quantity from host byte order to network byte order.