Title: Networking Summary
Course: CPS 261: Advanced Java Concepts ~ DL & MM MASTER

Networking Summary

Networking: TCP/IP and Basic Sockets

- Networking layered architecture:
  - Protocols like Http, Ftp, SMTP, IMAP, POP, Telnet sit on top of TCP/IP
  - TCP/IP (Transmission Control Protocol and Internet Protocol) layer
  - Hardware Layer: Ethernet, Wireless, Twisted Pair, etc.
- Socket Programming gives us an API to reliably send and receive packets of data from the TCP/IP layer. All of the protocols(Http, Ftp, etc.) make use of the this layer.
- EchoServerSingleThreaded.java example: Single Threaded Echo Server. Server waits on an "accept" call until a connection request comes in. A Socket data structure is returned from the "accept" call and it can be turned into an InputStream and OutputStream which then allows us to use our Scanner and PrintStream classes.
- EchoClient.java example: This class does a "connect" to some Server and also receives a Socket data structure. Again the client can convert the Socket into an InputStream or an OutputStream and use the Scanner and PrintStream classes to simplify communication.

Networking: Better Server Model

- In the previous video/notes we went over the basics of Sockets. However, the Server code example had many deficiencies. In this video/notes we create a better Server Architecture with the following advantages:
  - We can handle more than one conversation simultaneously
  - We can terminate threads more cleanly with the 2 classes: MotherServer.java and EchoServer.java
  - We can reuse the EchoServer logic by extending EchoServer to create other protocols: Rock-Paper-Scissors, Http Server, File Server

Networking: Sample Protocol Handlers

- By Extending EchoServer.java, you can then create new protocols: RPS_Server.java for Rock Paper Scissors.
- HttpServer.java - creating a minimal Http Web Server by extending EchoServer.java.
- You should now be able to put together your File Server for JH5.

Networking: Extra Odds and Ends

- This video/notes has some miscellaneous extra concepts for completeness.
  - Sending and receiving objects across TCP/IP using ObjectInputStream and ObjectOutputStream. To do this we have EchoObjectClient.java extending the EchoClient, and EchoObjectServer extending EchoServer. The ability to send and receive objects across a socket is important for our Networking Game Project.
  - GetUrl.java examample: using Sockets to create a primitive browser functionality.
  - URLReader.java example: demonstrates using the URL class to download a file.
  - Snoop.java example: a program that I used to use in industry to analyze protocols.
  - ShowDocument.java - contains an applet to demonstrate browser functionality. You will see an error on displaying this page because of the applet that is part of this example.

Last Modified: September 6, 2015 11:57 PM