Code example for ServerSocket

Methods: close

0
        } 
 
        public void tearDown() { 
            mThread.interrupt();
            try { 
                mServerSocket.close();
            } catch (IOException ioe) {
                Log.e(TAG, "Error when closing server socket.");
            } 
        } 
 
        class ServerThread implements Runnable {
 
            @Override 
            public void run() { 
 
                try { 
                    // Since discovery will happen via Nsd, we don't need to care which port is 
                    // used.  Just grab an available one  and advertise it via Nsd. 
                    mServerSocket = new ServerSocket(0);
                    setLocalPort(mServerSocket.getLocalPort());