Java 类com.jcraft.jsch.ChannelDirectTCPIP 实例源码

项目:spork-streaming    文件:SSHSocketImplFactory.java   
@Override
protected void connect(SocketAddress address, int timeout)
        throws IOException {
    try {
        if (!session.isConnected()) {
            session.connect();
        }
        channel = (ChannelDirectTCPIP) session.openChannel("direct-tcpip");
        //is = channel.getInputStream();
        //os = channel.getOutputStream();
        channel.setHost(((InetSocketAddress) address).getHostName());
        channel.setPort(((InetSocketAddress) address).getPort());
        channel.setOrgPort(22);
        is = new PipedInputStream();
        os = new PipedOutputStream();
        channel
                .setInputStream(new PipedInputStream((PipedOutputStream) os));
        channel
                .setOutputStream(new PipedOutputStream(
                        (PipedInputStream) is));
        channel.connect();
        if (!channel.isConnected()) {
            log.error("Not connected");
        }
        if (channel.isEOF()) {
            log.error("EOF");
        }
    } catch (JSchException e) {
        log.error(e);
        IOException newE = new IOException(e.getMessage());
        newE.setStackTrace(e.getStackTrace());
        throw newE;
    }
}
项目:PonIC    文件:SSHSocketImplFactory.java   
@Override
protected void connect(SocketAddress address, int timeout)
        throws IOException {
    try {
        if (!session.isConnected()) {
            session.connect();
        }
        channel = (ChannelDirectTCPIP) session.openChannel("direct-tcpip");
        //is = channel.getInputStream();
        //os = channel.getOutputStream();
        channel.setHost(((InetSocketAddress) address).getHostName());
        channel.setPort(((InetSocketAddress) address).getPort());
        channel.setOrgPort(22);
        is = new PipedInputStream();
        os = new PipedOutputStream();
        channel
                .setInputStream(new PipedInputStream((PipedOutputStream) os));
        channel
                .setOutputStream(new PipedOutputStream(
                        (PipedInputStream) is));
        channel.connect();
        if (!channel.isConnected()) {
            log.error("Not connected");
        }
        if (channel.isEOF()) {
            log.error("EOF");
        }
    } catch (JSchException e) {
        log.error(e);
        IOException newE = new IOException(e.getMessage());
        newE.setStackTrace(e.getStackTrace());
        throw newE;
    }
}
项目:sedge    文件:SSHSocketImplFactory.java   
@Override
protected void connect(SocketAddress address, int timeout)
        throws IOException {
    try {
        if (!session.isConnected()) {
            session.connect();
        }
        channel = (ChannelDirectTCPIP) session.openChannel("direct-tcpip");
        //is = channel.getInputStream();
        //os = channel.getOutputStream();
        channel.setHost(((InetSocketAddress) address).getHostName());
        channel.setPort(((InetSocketAddress) address).getPort());
        channel.setOrgPort(22);
        is = new PipedInputStream();
        os = new PipedOutputStream();
        channel
                .setInputStream(new PipedInputStream((PipedOutputStream) os));
        channel
                .setOutputStream(new PipedOutputStream(
                        (PipedInputStream) is));
        channel.connect();
        if (!channel.isConnected()) {
            log.error("Not connected");
        }
        if (channel.isEOF()) {
            log.error("EOF");
        }
    } catch (JSchException e) {
        log.error(e);
        IOException newE = new IOException(e.getMessage());
        newE.setStackTrace(e.getStackTrace());
        throw newE;
    }
}