Code example for LocalSocket

Methods: close, connect, getInputStream, getOutputStream

0
            return true; 
        } 
		 
        Log.i(TAG, "connecting...");
        try { 
            mSocket = new LocalSocket();
 
            LocalSocketAddress address = new LocalSocketAddress(
                "remote_control_service", LocalSocketAddress.Namespace.RESERVED);
 
            mSocket.connect(address);
 
            mIn = mSocket.getInputStream();
            mOut = mSocket.getOutputStream();
        } catch (IOException ex) {
        	Log.e(TAG, "connect exception:" + ex);
            disconnect(); 
            return false; 
        } 
        return true; 
    } 
 
	private void disconnect() { 
        Log.i(TAG,"disconnecting...");
		try { 
			if (mSocket != null) mSocket.close();
		} catch (IOException ex) { }
		 
		try { 
			if (mIn != null) mIn.close();
		} catch (IOException ex) { }