Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Java Network Programming
Dedication
Preface
About the Fourth Edition
Organization of the Book
Who You Are
Java Versions
About the Examples
Conventions Used in This Book
Request for Comments
Using Code Examples
SafariĀ® Books Online
How to Contact Us
Acknowledgments
1. Basic Network Concepts
Networks
The Layers of a Network
The Host-to-Network Layer
The Internet Layer
The Transport Layer
The Application Layer
IP, TCP, and UDP
IP Addresses and Domain Names
Ports
The Internet
Internet Address Blocks
Network Address Translation
Firewalls
Proxy Servers
The Client/Server Model
Internet Standards
IETF RFCs
W3C Recommendations
2. Streams
Output Streams
Input Streams
Marking and Resetting
Filter Streams
Chaining Filters Together
Buffered Streams
PrintStream
Data Streams
Readers and Writers
Writers
OutputStreamWriter
Readers
Filter Readers and Writers
PrintWriter
3. Threads
Running Threads
Subclassing Thread
Implementing the Runnable Interface
Returning Information from a Thread
Race Conditions
Polling
Callbacks
Futures, Callables, and Executors
Synchronization
Synchronized Blocks
Synchronized Methods
Alternatives to Synchronization
Deadlock
Thread Scheduling
Priorities
Preemption
Blocking
Yielding
Sleeping
Joining threads
Waiting on an object
Finish
Thread Pools and Executors
4. Internet Addresses
The InetAddress Class
Creating New InetAddress Objects
Caching
Lookups by IP address
Security issues
Getter Methods
Address Types
Testing Reachability
Object Methods
Inet4Address and Inet6Address
The NetworkInterface Class
Factory Methods
public static NetworkInterface getByName(String name) throws SocketException
public static NetworkInterface getByInetAddress(InetAddress address) throws SocketException
public static Enumeration getNetworkInterfaces() throws SocketException
Getter Methods
public Enumeration getInetAddresses()
public String getName()
public String getDisplayName()
Some Useful Programs
SpamCheck
Processing Web Server Logfiles
5. URLs and URIs
URIs
URLs
Relative URLs
The URL Class
Creating New URLs
Constructing a URL from a string
Constructing a URL from its component parts
Constructing relative URLs
Other sources of URL objects
Retrieving Data from a URL
public final InputStream openStream() throws IOException
public URLConnection openConnection() throws IOException
public final Object getContent() throws IOException
public final Object getContent(Class[] classes) throws IOException
Splitting a URL into Pieces
public String getProtocol()
public String getHost()
public int getPort()
public int getDefaultPort()
public String getFile()
public String getPath()
public String getRef()
public String getQuery()
public String getUserInfo()
public String getAuthority()
Equality and Comparison
Conversion
The URI Class
Constructing a URI
The Parts of the URI
Resolving Relative URIs
Equality and Comparison
String Representations
x-www-form-urlencoded
URLEncoder
URLDecoder
Proxies
System Properties
The Proxy Class
The ProxySelector Class
Communicating with Server-Side Programs Through GET
Accessing Password-Protected Sites
The Authenticator Class
The PasswordAuthentication Class
The JPasswordField Class
6. HTTP
The Protocol
Keep-Alive
HTTP Methods
The Request Body
Cookies
CookieManager
CookieStore
7. URLConnections
Opening URLConnections
Reading Data from a Server
Reading the Header
Retrieving Specific Header Fields
public String getContentType()
public int getContentLength()
public String getContentEncoding()
public long getDate()
public long getExpiration()
public long getLastModified()
Retrieving Arbitrary Header Fields
public String getHeaderField(String name)
public String getHeaderFieldKey(int n)
public String getHeaderField(int n)
public long getHeaderFieldDate(String name, long default)
public int getHeaderFieldInt(String name, int default)
Caches
Web Cache for Java
Configuring the Connection
protected URL url
protected boolean connected
protected boolean allowUserInteraction
protected boolean doInput
protected boolean doOutput
protected boolean ifModifiedSince
protected boolean useCaches
Timeouts
Configuring the Client Request HTTP Header
Writing Data to a Server
Security Considerations for URLConnections
Guessing MIME Media Types
HttpURLConnection
The Request Method
HEAD
DELETE
PUT
OPTIONS
TRACE
Disconnecting from the Server
Handling Server Responses
Error conditions
Redirects
Proxies
Streaming Mode
8. Sockets for Clients
Using Sockets
Investigating Protocols with Telnet
Reading from Servers with Sockets
Writing to Servers with Sockets
Half-closed sockets
Constructing and Connecting Sockets
Basic Constructors
Picking a Local Interface to Connect From
Constructing Without Connecting
Socket Addresses
Proxy Servers
Getting Information About a Socket
Closed or Connected?
toString()
Setting Socket Options
TCP_NODELAY
SO_LINGER
SO_TIMEOUT
SO_RCVBUF and SO_SNDBUF
SO_KEEPALIVE
OOBINLINE
SO_REUSEADDR
IP_TOS Class of Service
Socket Exceptions
Sockets in GUI Applications
Whois
A Network Client Library
9. Sockets for Servers
Using ServerSockets
Serving Binary Data
Multithreaded Servers
Writing to Servers with Sockets
Closing Server Sockets
Logging
What to Log
How to Log
Constructing Server Sockets
Constructing Without Binding
Getting Information About a Server Socket
Socket Options
SO_TIMEOUT
SO_REUSEADDR
SO_RCVBUF
Class of Service
HTTP Servers
A Single-File Server
A Redirector
A Full-Fledged HTTP Server
10. Secure Sockets
Secure Communications
Creating Secure Client Sockets
Choosing the Cipher Suites
Event Handlers
Session Management
Client Mode
Creating Secure Server Sockets
Configuring SSLServerSockets
Choosing the Cipher Suites
Session Management
Client Mode
11. Nonblocking I/O
An Example Client
An Example Server
Buffers
Creating Buffers
Allocation
Direct allocation
Wrapping
Filling and Draining
Bulk Methods
Data Conversion
View Buffers
Compacting Buffers
Duplicating Buffers
Slicing Buffers
Marking and Resetting
Object Methods
Channels
SocketChannel
Connecting
Reading
Writing
Closing
ServerSocketChannel
Creating server socket channels
Accepting connections
The Channels Class
Asynchronous Channels (Java 7)
Socket Options (Java 7)
Readiness Selection
The Selector Class
The SelectionKey Class
12. UDP
The UDP Protocol
UDP Clients
UDP Servers
The DatagramPacket Class
The Constructors
Constructors for receiving datagrams
Constructors for sending datagrams
The get Methods
public InetAddress getAddress()
public int getPort()
public SocketAddress getSocketAddress()
public byte[] getData()
public int getLength()
public int getOffset()
The setter Methods
public void setData(byte[] data)
public void setData(byte[] data, int offset, int length)
public void setAddress(InetAddress remote)
public void setPort(int port)
public void setAddress(SocketAddress remote)
public void setLength(int length)
The DatagramSocket Class
The Constructors
public DatagramSocket() throws SocketException
public DatagramSocket(int port) throws SocketException
public DatagramSocket(int port, InetAddress interface) throws SocketException
public DatagramSocket(SocketAddress interface) throws SocketException
protected DatagramSocket(DatagramSocketImpl impl) throws SocketException
Sending and Receiving Datagrams
public void send(DatagramPacket dp) throws IOException
public void receive(DatagramPacket dp) throws IOException
public void close()
public int getLocalPort()
public InetAddress getLocalAddress()
public SocketAddress getLocalSocketAddress()
Managing Connections
public void connect(InetAddress host, int port)
public void disconnect()
public int getPort()
public InetAddress getInetAddress()
public InetAddress getRemoteSocketAddress()
Socket Options
SO_TIMEOUT
SO_RCVBUF
SO_SNDBUF
SO_REUSEADDR
SO_BROADCAST
IP_TOS
Some Useful Applications
Simple UDP Clients
UDPServer
A UDP Echo Client
DatagramChannel
Using DatagramChannel
Opening a socket
Receiving
Sending
Connecting
Reading
Writing
Closing
Socket Options // Java 7
13. IP Multicast
Multicasting
Multicast Addresses and Groups
Clients and Servers
Routers and Routing
Working with Multicast Sockets
The Constructors
Communicating with a Multicast Group
Joining groups
Leaving groups and closing the connection
Sending multicast data
Loopback mode
Network interfaces
Two Simple Examples
Index
Colophon
Copyright
← Prev
Back
Next →
← Prev
Back
Next →