本文整理汇总了Java中com.trilead.ssh2.packets.Packets.SSH_MSG_CHANNEL_DATA属性的典型用法代码示例。如果您正苦于以下问题:Java Packets.SSH_MSG_CHANNEL_DATA属性的具体用法?Java Packets.SSH_MSG_CHANNEL_DATA怎么用?Java Packets.SSH_MSG_CHANNEL_DATA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.trilead.ssh2.packets.Packets
的用法示例。
在下文中一共展示了Packets.SSH_MSG_CHANNEL_DATA属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendData
public void sendData(Channel c, byte[] buffer, int pos, int len) throws IOException
{
while (len > 0)
{
int thislen = 0;
byte[] msg;
synchronized (c)
{
while (true)
{
if (c.state == Channel.STATE_CLOSED)
throw new IOException("SSH channel is closed. (" + c.getReasonClosed() + ")");
if (c.state != Channel.STATE_OPEN)
throw new IOException("SSH channel in strange state. (" + c.state + ")");
if (c.remoteWindow != 0)
break;
try
{
c.wait();
}
catch (InterruptedException ignore)
{
}
}
/* len > 0, no sign extension can happen when comparing */
thislen = (c.remoteWindow >= len) ? len : (int) c.remoteWindow;
int estimatedMaxDataLen = c.remoteMaxPacketSize - (tm.getPacketOverheadEstimate() + 9);
/* The worst case scenario =) a true bottleneck */
if (estimatedMaxDataLen <= 0)
{
estimatedMaxDataLen = 1;
}
if (thislen > estimatedMaxDataLen)
thislen = estimatedMaxDataLen;
c.remoteWindow -= thislen;
msg = new byte[1 + 8 + thislen];
msg[0] = Packets.SSH_MSG_CHANNEL_DATA;
msg[1] = (byte) (c.remoteID >> 24);
msg[2] = (byte) (c.remoteID >> 16);
msg[3] = (byte) (c.remoteID >> 8);
msg[4] = (byte) (c.remoteID);
msg[5] = (byte) (thislen >> 24);
msg[6] = (byte) (thislen >> 16);
msg[7] = (byte) (thislen >> 8);
msg[8] = (byte) (thislen);
System.arraycopy(buffer, pos, msg, 9, thislen);
}
synchronized (c.channelSendLock)
{
if (c.closeMessageSent == true)
throw new IOException("SSH channel is closed. (" + c.getReasonClosed() + ")");
tm.sendMessage(msg);
}
pos += thislen;
len -= thislen;
}
}
示例2: sendData
public void sendData(Channel c, byte[] buffer, int pos, int len)
throws IOException {
while (len > 0) {
int thislen = 0;
byte[] msg;
synchronized (c) {
while (true) {
if (c.state == Channel.STATE_CLOSED)
throw new IOException("SSH channel is closed. ("
+ c.getReasonClosed() + ")");
if (c.state != Channel.STATE_OPEN)
throw new IOException("SSH channel in strange state. ("
+ c.state + ")");
if (c.remoteWindow != 0)
break;
try {
c.wait();
} catch (InterruptedException ignore) {
}
}
/* len > 0, no sign extension can happen when comparing */
thislen = (c.remoteWindow >= len) ? len : (int) c.remoteWindow;
int estimatedMaxDataLen = c.remoteMaxPacketSize
- (tm.getPacketOverheadEstimate() + 9);
/* The worst case scenario =) a true bottleneck */
if (estimatedMaxDataLen <= 0) {
estimatedMaxDataLen = 1;
}
if (thislen > estimatedMaxDataLen)
thislen = estimatedMaxDataLen;
c.remoteWindow -= thislen;
msg = new byte[1 + 8 + thislen];
msg[0] = Packets.SSH_MSG_CHANNEL_DATA;
msg[1] = (byte) (c.remoteID >> 24);
msg[2] = (byte) (c.remoteID >> 16);
msg[3] = (byte) (c.remoteID >> 8);
msg[4] = (byte) (c.remoteID);
msg[5] = (byte) (thislen >> 24);
msg[6] = (byte) (thislen >> 16);
msg[7] = (byte) (thislen >> 8);
msg[8] = (byte) (thislen);
System.arraycopy(buffer, pos, msg, 9, thislen);
}
synchronized (c.channelSendLock) {
if (c.closeMessageSent == true)
throw new IOException("SSH channel is closed. ("
+ c.getReasonClosed() + ")");
tm.sendMessage(msg);
}
pos += thislen;
len -= thislen;
}
}