Monday, November 26, 2012

NetWork Fundation&Java Final Project - Problem Solving Log

TCP is analogous to Telephone.

UDP is analogous to Mailbox.

a Socket is sometimes called a pipe because there are two ends to the communication.

Java: Detecting client disconnects from server side

The best way to detect a disconnection is to have the other end send a heartbeat and have the reader timeout when there is no data.

Q1: 在while(true){}循环中,有那些语句可以暂停这些循环?
EX:
serversocket.accept();
clientSocketList.get(i).getInputStream().read()==-1

Q2: InputStream/ OutputStream的运作原理。


Class InputStream



read

public abstract int read()
                  throws IOException
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.



No comments:

Post a Comment