Winsock Programming - Windows API Reference

Introduction

The Winsock (Windows Sockets) API provides a standardized interface for developing network applications on Windows. It allows applications to communicate over TCP/IP and UDP protocols. This section provides an overview of the Winsock API and its key functions.

Functions

Function Name Description Parameters Return Value
WSAStartup Initializes the Winsock API. WSADATA TRUE if successful, FALSE otherwise.
closesocket Closes a socket. SOCKET TRUE if successful, FALSE otherwise.
accept Accepts a connection from a client. SOCKADDR_IN*, int* TRUE if successful, FALSE otherwise.
bind Binds a socket to a local address and port. SOCKADDR_IN*, int* TRUE if successful, FALSE otherwise.
connect Establishes a connection to a remote address. SOCKADDR_IN*, int* TRUE if successful, FALSE otherwise.
listen Listens for incoming connections on a socket. int* TRUE if successful, FALSE otherwise.
recv Receives data from a socket. void*, int* The number of bytes received, or 0 on error.
send Sends data from a socket. void*, int* The number of bytes sent, or 0 on error.
shutdown Shuts down the Winsock API. int* TRUE if successful, FALSE otherwise.