Anyone please help me understand this code. this is taken from the IPCamera from android which i take from the googlecode. the code that i was trying to figure out was:
public NanoHTTPD( int port, File wwwroot ) throws IOException
{
myTcpPort = port;
this.myRootDir = wwwroot;
myServerSocket = new ServerSocket( myTcpPort );
myThread = new Thread( new Runnable()
{
public void run()
{
try
{
while( true )
new HTTPSession( myServerSocket.accept());
}
catch ( IOException ioe )
{}
}
});
myThread.setDaemon( true );
myThread.start();
}
private class HTTPSession implements Runnable
{
public HTTPSession( Socket s )
{
mySocket = s;
Thread t = new Thread( this );
t.setDaemon( true );
t.start();
}
public void run()
{
try
{
InputStream is = mySocket.getInputStream();
if ( is == null) return;
Things that i want to know. please tell me if what i understand is wrong:
1- myServerSocket.accept()
what this code will return? boolean value as if true or false?
2- InputStream is = mySocket.getInputStream();
Input stream is to get the byte stream. but what the program read on mySocket. From what i understand, it reads on the port number. What it has to do with mySocket with to get the byte?
I am really sorry if my understanding is completely wrong as socket is not my knowledge. please help me to understand more on this.