This is a closed book exam to be turned in at 1:30 pm. Name: _____________________.
Give an example of how an IP number is written.
Give short definitions of the following terms.
remote port | |
URL | |
applet | |
javac | |
InetAddress |
Why are TCP servers almost always written with either child processes or
multiple threads?
Why would an method like the following one:
private static String unsignit(byte b) { if (b<0) return(Integer.toString((int)b+256)) ; else return(Byte.toString(b)) ; }
be useful in solving homework problem 2.
Why is error handling usually more important in networking applications
than in other applications?
Here's a section of code from the textbook.
while (true) { theConnection = theServer.accept() ; p = new PrintStream(theConnection.getOutputStream()) ; p.println(new Date()) ; theConnection.close() ; }
This loop is the body of a server for the daytime protocol which
send the day-of-time to any client which connects to it. What does the call
theServer.accept() do in this loop?
Here's an almost complete client to connect to the daytime TCP server running on port 13 of penrose.cs.unca.edu. Two expressions, indicated by the big underlined blank areas, are missing. Fill them in.
import java.net.*; import java.io.* ; class GetTime{ public static void main (String args[]) { Socket RemoteHostConnect ; BufferedReader RemoteInput ; try { Socket RemoteHostConnect = _____________________________________ ; BufferedReader RemoteInput = new BufferedReader( new InputStreamReader( RemoteHostConnect.getInputStream())) ; String TimeOfDay = _____________________________________________ ; System.out.println( TimeOfDay ) ; } catch ( IOException ioe ) { System.out.println("Oops") ; } } }
If you can't remember the exact name of a method, write in something that is close.