TCP/IP Sockets in Java: Practical Guide for Programmers
The networking capabilities of the Java platform have been extended considerably since the first edition of the book. This new edition covers version 1.5-1.7, the most current iterations, as well as making the following improvements:
The API (application programming interface) reference sections in each chapter, which describe the relevant parts of each class, have been replaced with (i) a summary section that lists the classes and methods used in the code, and (ii) a "gotchas" section that mentions nonobvious or poorly-documented aspects of the objects.
In addition, the book covers several new classes and capabilities introduced in the last few revisions of the Java platform. New abstractions to be covered include NetworkInterface, InterfaceAddress, Inet4/6Address, SocketAddress/InetSocketAddress, Executor, and others; extended access to low-level network information; support for IPv6; more complete access to socket options; and scalable I/O. The example code is also modified to take advantage of new language features such as annotations, enumerations, as well as generics and implicit iterators where appropriate.
Most Internet applications use sockets to implement network communication protocols. This book's focused, tutorial-based approach helps the reader master the tasks and techniques essential to virtually all client-server projects using sockets in Java. Chapter 1 provides a general overview of networking concepts to allow readers to synchronize the concepts with terminology. Chapter 2 introduces the mechanics of simple clients and servers. Chapter 3 covers basic message construction and parsing. Chapter 4 then deals with techniques used to build more robust clients and servers. Chapter 5 (NEW) introduces the scalable interface facilities which were introduced in Java 1.5, including the buffer and channel abstractions. Chapter 6 discusses the relationship between the programming constructs and the underlying protocol implementations in more detail. Programming concepts are introduced through simple program examples accompanied by line-by-line code commentary that describes the purpose of every part of the program. No other resource presents so concisely or so effectively the material necessary to get up and running with Java sockets programming.
What people are saying - Write a review
Other editions - View all
TCP/IP Sockets in Java: Practical Guide for Programmers
Kenneth L. Calvert,Michael J. Donahoo
Limited preview - 2001
accept address and port args args.length associated big-endian block boolean broadcast buffer busy waiting byte array byte stream ByteBuffer candidateID channel character encoding charset client and server client connection clntSock closing handshake compressed constructor created datagram DatagramChannel DatagramSocket delimiter echo protocol echo server encoding endpoint example factory method host I/O operations implementation import java.io.IOException InetAddress input InputStream integer interface Internet address IP address IPv4 IPv6 isResponse Java Java Virtual Machine lines logger method returns multicast address MulticastSocket netstat nonblocking number of bytes output stream packet port number provides public class public static final public static void RecvQ remote IP remote port routers SelectionKey selector sender SendQ sequence ServerSocket ServerSocketChannel Socket instance socket structure SocketAddress SocketChannel specified static final int static void main(String String TCP connection TCP socket TCP/IP thread throw new IllegalArgumentException("Parameter(s throws IOException timeout UDP socket underlying unicast voteCount write
Page ii - Architectures and Mechanisms Zheng Wang TCP/IP Sockets in Java: Practical Guide for Programmers Michael J. Donahoo and Kenneth L. Calvert TCP/IP Sockets in C: Practical Guide for Programmers Kenneth L. Calvert and Michael J. Donahoo Multicast Communication: Protocols, Programming, and Applications Ralph...
Page 3 - ... and delivered by the network independently, like telegrams or parcels sent via the postal system. To make this work, each IP packet has to contain the address of its destination, just as every package you mail is addressed to somebody. (We'll say more about addresses shortly.) Although most parcel delivery companies guarantee delivery of a package, IP is only a best-effort protocol: It attempts to deliver each packet, but it can (and occasionally does) lose, reorder, or duplicate packets in transit...
Page 7 - ... know the telephone number of the caller. How does a client find out a server's IP address and port number? Usually, the client knows the name of the server it wants, for example, from a Universal Resource Locator (URL) such as "http://www.mkp.com," and uses the name resolution service (see Chapter 7) to learn the corresponding Internet address. Finding a server's port number is a different story. In principle, servers can use any port, but the client must be able to learn what it is. In the Internet,...
Page 5 - ... uses the street address to get the letter to a mailbox; whoever empties the mailbox is then responsible for getting the letter to the proper room within the building. Or consider a company with an internal telephone system: To speak to an individual in the company, you first dial the company's main number to connect to the internal telephone system and then dial the extension of the particular telephone of the individual you wish to speak with. In these analogies, the Internet address is the...
Page 2 - In the context of computer networks these byte sequences are generally called packets. A packet contains control information that the network uses to do its job and sometimes also includes user data. An example is information about the packet's destination. Routers use such control information to figure out how to forward each packet. A protocol is an agreement about the packets exchanged by communicating programs and what they mean. A protocol tells how packets are structured— for example, where...