Code example for Socket

Methods: close, getInputStream, getOutputStream, setSoTimeout

0
        Socket andSocket = null;
        ObjectInputStream input = null;
        OutputStream output = null;
 
        try { 
            andSocket = new Socket( ip, port );
            andSocket.setSoTimeout( 500 ); //TODO settings
            output = andSocket.getOutputStream();
            yuvImage.compressToJpeg( new Rect( 0, 0, imageWidth, imageHeight), imageQuality, output );
 
            input = new ObjectInputStream( andSocket.getInputStream() );
            recivedValue = (SenseSocketData) input.readObject();
 
        } 
        catch ( IOException ex ) {
            SenseUtils.getLogger().logException( ex );
        } 
        catch ( ClassNotFoundException e ) {
            SenseUtils.getLogger().logException( e );
        } 
        finally { 
            try { 
                if ( andSocket != null )
                    andSocket.close();
                if ( output != null )
                    output.close();
                if ( input != null )
                    input.close();
            }