Code example for ServerSocket

Methods: bind, getLocalPort

0
	} 
 
	public void bind(InetSocketAddress addr)
	  throws IOException 
	{ 
		mSocket = new ServerSocket();
		mSocket.bind(addr);
		Log.i(TAG, "Bound to port " + mSocket.getLocalPort());
	} 
 
	public void setRequestHandler(HttpRequestHandler handler)
	{ 
		mReqHandler = handler;
	} 
 
	public int getPort() 
	{ 
		if (mSocket == null)
			throw new IllegalStateException("Not bound.");
 
		return mSocket.getLocalPort();