- Forward


TCP for Text Transport
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Transmission Control Protocol
Back SMYC Forward
  • Connection-Oriented, Point-to-Point, Full-Duplex
  • Reliable
  • Uses Flow Control
Connection-Oriented Protocols
Back SMYC Forward
  • 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
Back SMYC Forward
  • 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
Back SMYC Forward
  • 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
Back SMYC Forward
  • 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
Back SMYC Forward

The Process

javaexamples/internet/UppercaseEchoServer.java (Fragment: 1)
 
The Client Side
Back SMYC Forward

The Process

javaexamples/internet/TCPFileRetriever.java (Fragment: 1)
 
ServerSocket Objects and Threads
Back SMYC Forward
  • 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
Back SMYC Forward

An Uppercase Echo Server

javaexamples/internet/UppercaseEchoServer.java
 

The Driver

javaexamples/internet/UppercaseEchoServerDriver.java
 
There's Always More to Learn
Back -