Java Network Programming, Part 2: Sockets, Server Sockets, and UDP
Java Network Programming, Part 2: Sockets, Server Sockets, and UDP
Please turn off all
We will learn how Java handles
I assume you
Applet Network Security Restrictions
Datagrams
Packets Allow Error Correction
Abstraction
Sockets
Socket Operations
The java.net.Socket class
Constructing a Socket
Opening Sockets
Example
Example
Picking an IP address
Choosing a Local Port
Sending and Receiving Data
Reading Input from a Socket
Time Client
Writing Output to a Socket
Discard
Reading and Writing to a Socket
Example
Example
Example
Example
Better Example
Socket Options
Example
Servers
Server Sockets
Multiple Clients
Queueing
The java.net.ServerSocket Class
Constructors
Constructing Server Sockets
Example
Example
Expanding the Queue
Choosing an IP address
Example
Example
Example
Reading Data with a ServerSocket
Example
Better Example
Writing Data to a Client
Interacting with a Client
Threading
Adding Threading to a Server
Adding a Thread Pool to a Server
Example
Thread Pools
Setting Server Socket Options
Utility Methods
UDP
The UDP Classes
java.net.DatagramPacket
java.net.DatagramSocket
UDP ports
Two DatagramPacket Constructors
For example,
With a destination:
DatagramPackets are not immutable.
java.net.DatagramSocket
Sending UDP Datagrams
For example,
Receiving UDP Datagrams
For example,
To Learn More
Questions?
Entire Presentation as Single File
Start
|
Cafe con Leche
Copyright 2000
Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified November 8, 2000