Code example for Socket

Methods: close, setSoLinger

0
    } 
 
    private void closeWithLinger(boolean linger) {
        Log.d(TAG, "Socket linger test; linger=" + linger);
        try { 
            Socket socket = new Socket();
            socket.setSoLinger(linger, 5);
            socket.close();
        } catch (IOException e) {
            Log.e(TAG, "Error with linger close", e);
        } 
    } 
 
    private void fileReadLoop() { 
        RandomAccessFile raf = null;
        File filename = getFileStreamPath("test.dat");
        try { 
            long sumNanos = 0;
            byte[] buf = new byte[512];
 
            //raf = new RandomAccessFile(filename, "rw");