Chapter 9. Sockets for Clients
Data is transmitted across the Internet in packets of finite size
called
datagrams.
Each datagram contains a
header
and a
payload.
The header contains the address and port to which the packet is
going, the address and port from which the packet came, and various
other housekeeping information used to ensure reliable transmission.
The payload contains the data itself. However, since datagrams have a
finite length, it's often necessary to split the
data across multiple packets and reassemble it at the destination.
It's also possible that one or more packets may be
lost or corrupted in transit and need to be retransmitted or that
packets arrive out of order and need to be reordered. Keeping track
of thissplitting the data into packets, generating headers,
parsing the headers of incoming packets, keeping track of what
packets have and haven't been received, and so
onis a lot of work and requires a lot of intricate code.Fortunately, you don't have to do the work yourself.
Sockets allow the programmer to treat a
network connection as just another stream onto which bytes can be
written and from which bytes can be read. Sockets shield the
programmer from low-level details of the network, such as error
detection, packet sizes, packet retransmission, network addresses,
and more.
• Table of Contents• Index• Reviews• Reader Reviews• Errata• AcademicJava Network Programming, 3rd EditionBy
Elliotte Rusty Harold Publisher: O'ReillyPub Date: October 2004ISBN: 0-596-00721-3Pages: 706
Thoroughly revised to cover all the 100+ significant updates
to Java Developers Kit (JDK) 1.5, Java Network
Programming is a complete introduction to
developing network programs (both applets and applications)
using Java, covering everything from networking fundamentals
to remote method invocation (RMI). It includes chapters on
TCP and UDP sockets, multicasting protocol and content
handlers, servlets, and the new I/O API. This is the
essential resource for any serious Java developer.