Code example for LocalSocketAddress

0
        } 
    } 
 
    private synchronized void openSocket() throws IOException { 
        LocalSocketAddress socketAddress =
                new LocalSocketAddress("/dev/socket/usbd", LocalSocketAddress.Namespace.FILESYSTEM);
 
        mSocket = new LocalSocket();
        mSocket.connect(socketAddress);
        mOutputStream = mSocket.getOutputStream();
    } 
 
    private void listenToSocket() throws IOException { 
        InputStream usbdInputStream = mSocket.getInputStream();
        byte[] buffer = new byte[100];
 
        while (true) { 
            int count = usbdInputStream.read(buffer);
 
            if (count < 0) {
                throw new IOException("Unexpected end of stream");