Code example for ServerSocket

Methods: close

        public void tearDown() { 
            try { 
            } catch (IOException ioe) {
                Log.e(TAG, "Error when closing server socket.");
        class ServerThread implements Runnable {
            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);
Connect your IDE to all the code out there  Get Codota for Java