theTime = input.nextLine();
//Add the host's response to the text in
display.append("The date/time at " + host
+ " is " + theTime + "\n");
catch (UnknownHostException uhEx)
display.append("No such host!\n");
catch (IOException ioEx)
display.append(ioEx.toString() + "\n");
socket.close(); //Close link to host.
"Unable to disconnect!");
If we run this program and enter ivy.shu.ac.uk as our host name in the client's
GUI, the result will look something like that shown in Fig. 2.7.
Unfortunately, it is rather diffi cult nowadays to fi nd a host that is running the
Daytime protocol. Even if one does fi nd such a host, it may be that the user's own
fi rewall blocks the output from the remote server. If this is the case, then the user
will be unaware of this until the connection times out—which may take some time!
The user is advised to terminate the program (with Ctrl-C) if the waiting time
appears to be excessive. One possible way round this problem is to write one's own