TCP for Text Transport
An Introduction with Examples in Java
|
Prof. David Bernstein
James Madison University
|
|
Computer Science Department
|
bernstdh@jmu.edu
|
Transmission Control Protocol
- Connection-Oriented, Point-to-Point, Full-Duplex
- Reliable
- Uses Flow Control
Connection-Oriented Protocols
- Conceptual:
- Like a telephone
- Must distinguish between full-duplex (telephone) and
half-duplex (string and can)
- Under the Hood:
- Handhsaking procedure used at the beginning
- Buffers and state variables kept at both ends
Reliable Protocols
- Conceptual:
- Delivery of packets is guaranteed
- Packets will be delivered in order
- Under the Hood:
- Acknowledgement of receipt/delivery
- Retransmission of lost packets
Protocols with Flow Control
- Conceptual:
- Ensure that neither side overwhelms the other by
sending too many packets too quickly
- Under the Hood:
- Buffers
- Variable transmission rates
The Client-Server Concept
- Initiating a Connection:
- One party must initiate the connection
- The initiating party is often called the client
- The other party is often called the server
- An Important Observation:
- At the application level, the initiator may not
be the client (in an architectural sense)
The Server Side
The Process
javaexamples/internet/UppercaseEchoServer.java
(Fragment: 1)
The Client Side
The Process
javaexamples/internet/TCPFileRetriever.java
(Fragment: 1)
ServerSocket
Objects and Threads
- What Thread?
- The
accept()
method blocks so, in most cases,
it will need to be called in a thread of execution
controlled by the server
- Timing Out:
- If you want to be able to stop the thread of execution
you need to have the
accept()
method time-out
The Server Side - A Complete Example
An Uppercase Echo Server
javaexamples/internet/UppercaseEchoServer.java
The Driver
javaexamples/internet/UppercaseEchoServerDriver.java
There's Always More to Learn