Example usage for org.apache.commons.net.io SocketInputStream SocketInputStream

List of usage examples for org.apache.commons.net.io SocketInputStream SocketInputStream

Introduction

In this page you can find the example usage for org.apache.commons.net.io SocketInputStream SocketInputStream.

Prototype

public SocketInputStream(Socket socket, InputStream stream) 

Source Link

Document

Creates a SocketInputStream instance wrapping an input stream and storing a reference to a socket that should be closed on closing the stream.

Usage

From source file:rnaedit.test.RExecClient.java

InputStream _createErrorStream() throws IOException {
    ServerSocket server;/*from  www.  j ava 2s.  c o  m*/
    Socket socket;

    server = _socketFactory_.createServerSocket(0, 1, getLocalAddress());

    _output_.write(Integer.toString(server.getLocalPort()).getBytes());
    _output_.write('\0');
    _output_.flush();

    socket = server.accept();
    server.close();

    if (__remoteVerificationEnabled && !verifyRemote(socket)) {
        socket.close();
        throw new IOException("Security violation: unexpected connection attempt by "
                + socket.getInetAddress().getHostAddress());
    }

    return (new SocketInputStream(socket, socket.getInputStream()));
}