This program makes a Socket, makes a BufferedReader (with the help of other streams), and reads a single line from the server application (whatever is running at port 4242).
Sharpen your pencil
Test your memory of the streams/classes for reading and writing from a Socket. Try not to look at the opposite page!
To read text from a Socket:
To send text to a Socket:
Sharpen your pencil
Fill in the blanks:
What two pieces of information does the client need in order to make a Socket connection with a server? _____________________ _____________________
Which TCP port numbers are reserved for ‘well-known services’ like HTTP and FTP? _____________________
TRUE or FALSE: The range of valid TCP port numbers can be represented by a short primitive? _____________________
You are currently reading a PREVIEW of this book.
Get instant access to over
$1 million worth of books and videos.