Network Programming with Sockets
Sockets appeared in Berkeley Unix (BSD = Berkeley
Software Distribution) for the first time.
For that reason, they are also called Berkeley Sockets.
Since Berkely Sockets were implemented in Unix Systems
originally, they have a long history connected
with Unix history. In the meantime, the BSD Sockets idea
proofed to be good enough for other operating systems
as well and so they are also available on other
popular systems like Windows.
The term Socket has two meanings.
- A Socket - when refered to as Network Socket - is the
information tupel (IP Adress, Port Number ). IP Address
is provided by the UP Protocol, Port Number is stored
in TCP or UDP - not in IP as many people believe!
Please have a look at the Literature section below.
- In Unix a Socket is an internal data structure, that
can be connected to a communication endpoint. The type of
connection can be various and depends on the Unix implementation
and Kernel configuration. On a typical Unix flavoured System
you have support for IP (Internet Protocol), TCP (Transmission Control
Program), UDP (User Datagram Protocol) and Unix Domain Sockets -
a Unix IPC (Interprocess Communication), a very fast
Communication channel soley found on Unix based systems.
One might find support for many other protocols like
X.25, RUDP (Reliable UDP), ...
For the application programmer, the socket is "visible"
as a File Descriptor. The Programmer can treat a socket
similar to a file and apply read(), write(), ioctl(), ...
on it. This is the strength of the concept, but
on the other hand a TCP connection is not a file and
this difference maks socket Programming a bit tricky.
It is not too hard to get something to work in
reasonable time (please see also the Examples section),
but to achieve ~ 100% reliability one needs a little bit
of experience.
Network Programming is calling for a framework that addresses
all the lower level issues so the application programmer
can focus on the higher level problems.
C++ World have developed their own C++ socket library,
you can learn more about it here.
Literature
- Richard Stevens "Unix Network Programming" has
been a classic for many years. "Could you borrow me
your Stevens, please?" is a phrase you hear quite
often in developer labs. The book is good for Windows
developers as well - not only because you can use Cygwin
and "bypass" the Unix API - but also because lots of the
System calls are industry standard (IEEE, POSIX).
The book covers Berkely sockets, System V Transport Layer
Interface (TLI), many protocols and their implementation
(RPC, telnet, rlogin, rmt, lpr)
|
|
-
Comer and Stevens wrote a series of three books on
"Internetworking with TCP/IP". I am using Volume II and
Volume III. Volume II (Design, Implmentation and Internals)
tells about the concept of TCP/IP protocols. It gives details
about the TCP finite state machine as well as about
SNMP, multicasting, urgent data, ospf (routing protocol).
This is not a real programmers book, it is exaplaining
conceptually how network programming works, from client
and server perspective and also from the operating
systems perspective. A very good book.
Volume III is more programming oriented. All aspects of client/server
computing are covered with lots of details and examples and pracatical
hints. It is a good follow up of Volume II. I assume Volume I
is good as well, but I have not read it.
|
|
|
|
-
Again Richard Stevens. TCP/IP Illustrated Vol 1. shows detailed
message charts and state transition charts of many network protocols.
IP, UDP, TCP, NFS, FTP, TFTP, BOOTP, DNS, SMTP, Telnet, Rlogin
Protocols are explained in detail. Broadcasting, multicasting,
message flows etc are also covered.
|
|