Code example for LocalSocket

Methods: close, connect, getInputStream, getOutputStream

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