@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;
}
}
java类com.jcraft.jsch.ChannelDirectTCPIP的实例源码
SSHSocketImplFactory.java 文件源码
项目:spork-streaming
阅读 28
收藏 0
点赞 0
评论 0
SSHSocketImplFactory.java 文件源码
项目:PonIC
阅读 29
收藏 0
点赞 0
评论 0
@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;
}
}
SSHSocketImplFactory.java 文件源码
项目:sedge
阅读 32
收藏 0
点赞 0
评论 0
@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;
}
}