Windows Sockets Programming
From Web (09.10.1996)
Table of Contents
This page is designed to give the programmer enough information to know where to look to get
the actual information.
Windows Sockets, or Winsock, is a .DLL which allows applications to talk over a network,
usually the Internet. The .DLL is usually called WINSOCK.DLL.
Unlike all other .DLLs, there isn't an official WINSOCK.DLL in the sense that there is say
a 'common dialog' COMMDLG.DLL or a 'control 3d' CTL3DV2.DLL. When you get WINSOCK, you get
it from a particular vendor. Each different version is slightly different in terms of how it
is configured, but once it is configured properly each .DLL should have the same functions
and properly written applications will work with whatever Winsock you are using.
Popular Winsocks are:
This Winsock is shareware. It has the ability to talk over an Ethernet board or over a modem
to an Internet provider, but it can't do both simultaneously. Note that if you don't have a
network card or an Internet provider account you can still write and test programs running both
the client and server on your machine, provided you have a serial port. You can FTP the old
unlimited Trumpet from
For Trumpet-specific info, check out the newsgroup
The Trumpet WWW site
Australia and I have had difficulty getting into it. You can also get Trumpet from
Stroud's CWSApps List.
There are two version of Trumpet. The 1.x version can connect via modem with SLIP, the 2.x versions
can use SLIP or PPP. 2.0b never expired.
This Winsock is freeware. It only works with Windows for Workgroups, and only over an Ethernet.
It was written by Microsoft
. You can FTP the files from
This Winsock is a commercial product. It provides a way to write DOS programs which talk over
networks as well. It only works over Ethernet, Token-Ring, SLIP, PPP,
and X.25 (as well as some other little used topologies). I've only used it
Windows 95 Winsock:
This Winsock comes with Windows 95. It works over the Modem or most network cards.
Windows95.com Internet TCP/IP Connectivity
for more information.
Windows NT Winsock:
This Winsock comes included with Windows NT. It can talk over an Ethernet board and over a modem
simultaneously. For instructions on connecting to the Internet with your modem, see
Remote Access Services
Another source of information on NT winsock is
The Windows NT Internet FAQ 1 of 2
The Windows NT Internet FAQ 2 of 2
The biggest problem with having so many different kinds of Winsocks is that you will almost
certainly have problems if you have more than one WINSOCK.DLL on your system. Developers need
to keep and run multiple versions for testing and users seem to get different versions from each
Internet provider they sign up for. There is no good solution to this problem, as far as I
There is also a thing called
TIA which lets people with shell accounts run
Winsock software over the Internet.
You need a .h file which lists the data types and function calls used by Winsock. If you are
programming 16 bit Windows 3.1 or WfWG 3.11 apps, you also need WINSOCK.LIB so that you can
link. You also want the .HLP file which contains the documentation.
You can get all of these things from
Stardust Winsock 1.1 Development Components
Here is what is provided:
Note that it doesn't matter whose Winsock you are using, the same .LIB file works with all 16
bit programs, and you don't need a .LIB for 32 bit programs. Also note that these versions
are a bit more recent than the version in the WINSOCK.HLP normally shipped with BC++.
If you are using Borland
C++ 4.0 you got a free WINSOCK.HLP and
WINSOCK.H, but no WINSOCK.DLL,
so your programs can't link. You can use the provided IMPLIB to make a WINSOCK.LIB from your
TCP/IP is the Internet Protocol. Most Winsocks speak TCP/IP.
If you are on a NetWare
lan, your LAN might speak
IPX/SPX as its native protocol. That doesn't
matter, because in most cases TCP/IP and IPX/SPX can live on the same Ethernet in harmony, not
even being aware of the other's existance. To get this to work with Trumpet you will have
to alter your NET.CFG.
If you are connecting to the Internet with a modem, you are probably used to the way that a
communications terminal program, like Windows Terminal, dials a phone number and then each
character sent over the modem reaches the other 'end', where the other end is some program
running on the computer in charge of the modem at the other end.
Network protocols don't work like this. On the Internet, each machine is given an address which
is four numbers, such as 188.8.131.52. You send data in chunks called 'packets' and you tell TCP/IP
the address of the machine that you want to get the data, and the 16 bit 'socket number' of
the program running on that machine that you want to get the data. TCP/IP sends your packet
and provides a way for the other program to get a response back to you.
Are there any books on Winsock?
There are many. The first one was called Programming Winsock by Arthur Dumas,
ISBN: 0-672-30594-1, $35.00 US
I didn't like it. All of the examples were in Visual C++, and I found typos. It also doesn't
have a lot of winsock-specific information that isn't provided with the WINSOCK.HLP file. It is,
however, the only book which exclusively covers Winsock. I think it would be a good book if you
didn't know anything about TCP/IP programming but knew Windows and wanted to learn.
There are some other books out or on the way which discuss Winsock. I don't have a full list here,
so if you wrote a book and you don't see it send me a note. One book that is very interesting
Windows Sockets Network Programming
by Bob Quinn and David K. Shute.
Where can I get example source code?
What about Telnet?
The source for NCSA telnet is out there, but it doesn't work with Winsock. I believe it writes
directly to packet drivers.
What about a WWW browser?
If you are an education institution you can get the source code for NCSA Mosaic. There
are also WWW custom controls available, from Microsoft and others, that you can use
in your own programs.
POP3 mail client?
Developing a POP3 client is an ongoing series in Doctor Dobbs. To download the source code,
go to ftp://ftp.mv.com/pub/ddj
and get the code from
the 1995.04, 1995.05, and 1995.06 directories.
Ping is a non-standard extension to the Winsock 1.1. For a basic Ping that works with some
Chapter 16 of the book Windows Sockets Network Programming
For source code to an actual Winsock .DLL, there is the Waterloo Winsock:
I haven't looked at this in a while. Waterloo made a free TCP/IP stack for DOS before the days
of Winsock. I believe this either sat on top of their TCP/IP stack for DOS or possibly on top
of a packet driver. It is a pretty old program, and it is getting scarce.
Where is Winsock discussed?
On Usenet, in
There are also mailing lists for people designing Winsock 2.0, see
for more details.
Where can I get Winsock programming information on the World Wide Web?
is a good site, if you can get into it.
also has some good information.
Where is the comp.protocols.tcp-ip.ibmpc Frequently Asked Questions (FAQ)
is a sort of Winsock
BSD Sockets: A Quick and Dirty Primer
TCP/IP on the PC: Getting Equipped
Where can I get Windows sockets applications in general?
Stroud's Consummate Winsock, http://cws.wilmington.net,
is a good place to find out about the latest
How come I am getting linker errors when I compile?
A lot of WINSOCK.LIB files floating around have lower case symbols when they
should have upper case
symbols. Often, if you tell your compiler you don't want a 'case sensative link'
or 'case sensitive import'
you will have better luck.
Are there C++ class libraries for Winsock?
There are. A good resource is Winsock Development Tools
. Visual C++ has included
libraries since version 2.1. Borland C++ has them in version 5.0.
For OWL users, there is a class
Many books also develop socket libraries.
What about all of these new Microsoft APIs
Microsoft has many new layers above Winsock which are supposed to make programming
easier and lock you into their libaries. Currently you can get something called
The ActiveX SDK
which includes all kinds of stuff. Basically, Microsoft's plan is to add a bunch of
new Win32 APIs and OLE/COM controls so that you can do FTP and WWW stuff without
What about Java? How is that related to Winsock?
Java is a new C++-like language. It allows programs to load off the Internet and run inside
your Web Browser. See Welcome to my Java testing for more info.
What is WSOCK32.DLL? also, How do I get Trumpet to work with Windows 95?
WSOCK32.DLL is a thunk to let Win32s programs use WINSOCK.DLL. It comes with Win32s, I believe.
You need this if you are running a 32 bit program with Trumpet or other 16 bit Winsock. It
doesn't do anything except let Win32s programs call Winsock. If you are running NT or Win95,
you want to use the built-in networking, not a second TCP/IP stack.
Note: The Win95 preview doesn't work with Dynamic SLIP as far as anyone knows. So if your
provider gives you that, you need to get changed to a permanent IP number unless there is a
better Win95 soon.
Ed Snible's home page
N© This page is in the public domain.