Docsity

TCP Network Programming Assignment 1 for CPSC 5157 Computer Networks Course - Prof. Edward, Assignments of Computer Systems Networking and Telecommunications

Toggle sidebar
bg1
CPSC 5157 Computer Networks
Programming Assignment 1 Due Wednesday, September 24, 2008
This program is based on Section 2.7 of the 4th edition of the textbook,
Socket Programming with TCP.
NOTE: This was revised on Wednesday, September 17.
See notes 5 & 6, just below.
Implement and run the following code, written and discussed in the textbook.
TCPClient.java page 164 of the 4th edition.
page 158 of the 3rd edition.
TCPServer.java page 168 of the 4th edition.
page 162 of the 3rd edition.
NOTES:
1. When writing these two programs, put them in the same project.
2. When running these two programs, start the Server first.
3. The reference “hostname” in the Client code probably should be
replaced by “localhost”. This works; it defines a loop–back address,
so that the client and server are running on the same computer.
4. The book prefers BufferedReader. You may want to use Scanner for input.
I shall try this as an option. I was able to use Scanner, as in
Scanner inFromUser = new Scanner(System.in);
sentence = inFromUser.nextLine();
5. IMPORTANT POINT: The client and server must be separate processes.
In my implementation, both TCPClient and TCPServer are in the same project.
I used the BlueJ product to write and run the Java code.
I opened BlueJ twice; thus having two instances of BlueJ running.
I first opened BlueJ and ran TCPServer.java. This started the server.
I then opened BlueJ again and ran TCPClient.java. This started the client.
6. I had some trouble displaying the I/O windows in BlueJ. I found that the easiest
way to force the windows to appear was to have each program start with output.
I wrote my TCPServer with the following line before the loop structure.
System.out.println (“Server has started”);
I wrote my TCPClient to prompt for input with the statement
System.out.println (“Input a sentence”);
Revised on 9/18/2008

Partial preview of the text

Download TCP Network Programming Assignment 1 for CPSC 5157 Computer Networks Course - Prof. Edward and more Assignments Computer Systems Networking and Telecommunications in PDF only on Docsity!

CPSC 5157 Computer Networks

Programming Assignment 1 Due Wednesday, September 24, 2008

This program is based on Section 2.7 of the 4th^ edition of the textbook, Socket Programming with TCP. NOTE: This was revised on Wednesday, September 17. See notes 5 & 6, just below. Implement and run the following code, written and discussed in the textbook. TCPClient.java page 164 of the 4th^ edition. page 158 of the 3rd^ edition. TCPServer.java page 168 of the 4th^ edition. page 162 of the 3rd^ edition. NOTES:

  1. When writing these two programs, put them in the same project.
  2. When running these two programs, start the Server first.
  3. The reference “hostname” in the Client code probably should be replaced by “localhost”. This works; it defines a loop–back address, so that the client and server are running on the same computer.
  4. The book prefers BufferedReader. You may want to use Scanner for input. I shall try this as an option. I was able to use Scanner, as in Scanner inFromUser = new Scanner(System.in); sentence = inFromUser.nextLine();
  5. IMPORTANT POINT: The client and server must be separate processes. In my implementation, both TCPClient and TCPServer are in the same project. I used the BlueJ product to write and run the Java code. I opened BlueJ twice; thus having two instances of BlueJ running. I first opened BlueJ and ran TCPServer.java. This started the server. I then opened BlueJ again and ran TCPClient.java. This started the client.
  6. I had some trouble displaying the I/O windows in BlueJ. I found that the easiest way to force the windows to appear was to have each program start with output. I wrote my TCPServer with the following line before the loop structure. System.out.println (“Server has started”); I wrote my TCPClient to prompt for input with the statement System.out.println (“Input a sentence”); Revised on 9/18/