Home

Winsock

Winsock, short for Windows Sockets, is the Windows API that enables software running on Microsoft Windows to access network services using the Berkeley sockets interface. It provides a standard set of socket-level functions for creating, configuring, and using both stream-oriented (TCP) and datagram (UDP) sockets, as well as facilities for address and name resolution and asynchronous I/O. The API is exposed to applications through the Ws2_32.dll library and sits between user-mode software and the Windows networking stack.

History and scope: Winsock originated in the early 1990s as Winsock 1.x and was followed by Winsock

Programming model: Applications initialize the API with WSAStartup to request a version, then create sockets with

Portability and usage: Winsock abstracts Windows networking and supports both IPv4 and IPv6. Applications link against

2
in
the
late
1990s.
Winsock
2
added
IPv6
support,
a
more
flexible
provider
model,
enhanced
name-resolution
routines
(getaddrinfo,
getnameinfo),
and
improved
asynchronous
I/O
and
performance.
A
Layered
Service
Provider
mechanism
allowed
software
to
intercept
or
extend
Winsock
calls,
though
newer
Windows
versions
emphasize
built-in
capabilities
and
alternative
extensibility
methods.
socket(),
and
use
bind(),
listen(),
and
accept()
for
servers
or
connect()
for
clients.
Data
transfer
uses
send/recv
or
their
datagram
counterparts
sendto/recvfrom,
and
sockets
are
closed
with
closesocket.
For
name
resolution,
getaddrinfo
and
getnameinfo
are
preferred
over
older
utilities.
Non-blocking
and
asynchronous
I/O
can
be
achieved
with
select,
WSAEventSelect,
or
overlapped
I/O
using
WSASend/WSARecv
and
completion
ports.
Ws2_32.lib
and
run
on
Windows
platforms
with
Winsock
support.
The
API
remains
a
foundational
component
for
network-enabled
Windows
applications
and
services.