Code example for LocalServerSocket

0
    private LocalServerSocket mServerSocket = null;
 
    @Override public void onCreate() { 
        Log.v(TAG, "onCreate");
        try { 
            mServerSocket = new LocalServerSocket(SOCKET_NAME);
        } catch (IOException e) {
            Log.v(TAG, "in onCreate, making server socket: " + e);
            return; 
        } 
 
        Thread t = new Thread() {
                @Override public void run() { 
                    LocalSocket socket = null;
                    while (true) { 
                        try { 
                            Log.v(TAG, "Waiting for connection...");
                            socket = mServerSocket.accept();
                            Log.v(TAG, "Got socket: " + socket);
                            if (socket != null) {
                                startEchoThread(socket);