Chapter 18 - Networking: 2003 Prentice Hall, Inc. All Rights Reserved
Chapter 18 - Networking: 2003 Prentice Hall, Inc. All Rights Reserved
Chapter 18 - Networking
Outline
18.1 Introduction
18.2 Manipulating URLs
18.3 Reading a File on a Web Server
18.4 Establishing a Simple Server Using Stream Sockets
18.5 Establishing a Simple Client Using Stream Sockets
18.6 Client/Server Interaction with Stream Socket Connections
18.7 Connectionless Client/Server Interaction with Datagrams
18.8 Client/Server Tic-Tac-Toe Using a Multithreaded Server
18.9 Security and the Network
18.10 DeitelMessenger Chat Server and Client
18.10.1 DeitelMessengerServer and Supporting Classes
18.10.2 DeitelMessenger Client and Supporting Classes
18.11 NIO Networking Overview
Chapter 18 - Networking
18.1 Introduction
SiteSelector.ja
va
ReadServerFile.
java
Client.java
TicTacToeClient
.java
TicTacToeClient
.java
• Chat rooms
– Each user can post a message and read all other messages
– Multicast
• Send packets to groups of clients
Server listening on port 5000 ...
Connection received from: SEANSANTRY/XXX.XXX.XXX.XXX
Connection received from: PJD/XXX.XXX.XXX.XXX
Maximum message
sizein2003
bytes
Prentice Hall, Inc.
All rights reserved.
1 // Fig. 18.13: MessageListener.java Outline
2 // MessageListener is an interface for classes that wish to
3 // receive new chat messages.
4 package com.deitel.messenger; MessageListener
5
6 public interface MessageListener {
.java
7
8 // receive new chat message Method
Line 9
9 public void messageReceived( String from, String message ); messageReceived
10 } allows an
implementing class to
receive messages
DeitelMessenger
.java
DeitelMessenger
.java
• Non-blocking I/O
• Readiness selection
– Selectors
• SelectableChannel
• Selector
• Architectural patterns
– Promote loose coupling among subsystems
– Specify all subsystems and how they interact with each other
modifies notifies
Client tier
(Top tier)
Information tier
(Bottom tier) Database