Professional Documents
Culture Documents
17 Networking
17 Networking
CSc 335
Object-Oriented Programming and Design
Craig Barber, Ian Vasquez, Rick Snodgrass, Rick Mercer
Networking
Type Resolution Compile-Time
Type Checking Run-Time
Java API
Java Language
Anonymous
Exceptions
Classes
Java Swing
Coupling/ Design
Javadoc Teams PITL Patterns
Cohesion
OO Design UML
Reading
Inheritance
others’ Class Sequence Package
Hierarchy
code Diagrams Diagrams Diagrams
N-2
Refactoring Refactoring Y-2
Outline
• Types of Networking
Client - Server
Many clients connect with one server.
Clients communicate only with server.
Peer-to-Peer
Clients connect to a group of other clients, with no server.
Clients communicating directly with each-other.
• Disadvantage:
Relies on one main
server for entire
operation
recv( )
send( )
close( ) close( )
controlled by
application process
process
developer socket
socket
controlled by TCP with
TCP with
operating buffers, internet
system buffers,
variables
variables
Networking with Java N-8
Outline
• Networking in Java
Sockets
Streams
Decorating Streams
• Summary
Process Process
Server Socket
Socket
Output
Socket Socket
Input
Socket
Socket
Input
Socket
Client Machine
Process
Socket
ObjectInputStream input
= new ObjectInputStream(connection.getInputStream());
ObjectInputStream input
= new ObjectInputStream(server.getInputStream());