Code example for LocalSocket

Methods: close, connect, getInputStream, getOutputStream

0
        if (mSocket != null) {
            return true; 
        } 
        Log.i(TAG, "connecting...");
        try { 
            mSocket = new LocalSocket();
 
            LocalSocketAddress address = new LocalSocketAddress(
                "installd", LocalSocketAddress.Namespace.RESERVED);
 
            mSocket.connect(address);
 
            mIn = mSocket.getInputStream();
            mOut = mSocket.getOutputStream();
        } catch (IOException 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) { }
		try {