当前位置: 首页>>代码示例>>Java>>正文


Java ChannelCondition.STDERR_DATA属性代码示例

本文整理汇总了Java中com.trilead.ssh2.ChannelCondition.STDERR_DATA属性的典型用法代码示例。如果您正苦于以下问题:Java ChannelCondition.STDERR_DATA属性的具体用法?Java ChannelCondition.STDERR_DATA怎么用?Java ChannelCondition.STDERR_DATA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.trilead.ssh2.ChannelCondition的用法示例。


在下文中一共展示了ChannelCondition.STDERR_DATA属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

@Override
public int read(byte[] buffer, int start, int len) throws IOException {
	int bytesRead = 0;

	if (session == null)
		return 0;

	int newConditions = session.waitForCondition(conditions, 0);

	if ((newConditions & ChannelCondition.STDOUT_DATA) != 0) {
		bytesRead = stdout.read(buffer, start, len);
	}

	if ((newConditions & ChannelCondition.STDERR_DATA) != 0) {
		byte discard[] = new byte[256];
		while (stderr.available() > 0) {
			stderr.read(discard);
		}
	}

	if ((newConditions & ChannelCondition.EOF) != 0) {
		close();
		onDisconnect();
		throw new IOException("Remote end closed connection");
	}

	return bytesRead;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:SSH.java

示例2: read

@Override
public int read(byte[] buffer, int start, int len) throws IOException {
	int bytesRead = 0;

	if (session == null)
		return 0;

	int newConditions = session.waitForCondition(conditions, 0);

	if ((newConditions & ChannelCondition.STDOUT_DATA) != 0) {
		bytesRead = stdout.read(buffer, start, len);
	}

	if ((newConditions & ChannelCondition.STDERR_DATA) != 0) {
		byte discard[] = new byte[256];
		while (stderr.available() > 0) {
			stderr.read(discard);
		}
	}

	if ((newConditions & ChannelCondition.EOF) != 0) {
		onDisconnect();
		throw new IOException("Remote end closed connection");
	}

	return bytesRead;
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:27,代码来源:SSH.java

示例3: waitForCondition

/**
 * Wait until for a condition.
 * 
 * @param c
 *            Channel
 * @param timeout
 *            in ms, 0 means no timeout.
 * @param condition_mask
 *            minimum event mask
 * @return all current events
 * 
 */
public int waitForCondition(Channel c, long timeout, int condition_mask)
{
	long end_time = 0;
	boolean end_time_set = false;

	synchronized (c)
	{
		while (true)
		{
			int current_cond = 0;

			int stdoutAvail = c.stdoutWritepos - c.stdoutReadpos;
			int stderrAvail = c.stderrWritepos - c.stderrReadpos;

			if (stdoutAvail > 0)
				current_cond = current_cond | ChannelCondition.STDOUT_DATA;

			if (stderrAvail > 0)
				current_cond = current_cond | ChannelCondition.STDERR_DATA;

			if (c.EOF)
				current_cond = current_cond | ChannelCondition.EOF;

			if (c.getExitStatus() != null)
				current_cond = current_cond | ChannelCondition.EXIT_STATUS;

			if (c.getExitSignal() != null)
				current_cond = current_cond | ChannelCondition.EXIT_SIGNAL;

			if (c.state == Channel.STATE_CLOSED)
				return current_cond | ChannelCondition.CLOSED | ChannelCondition.EOF;

			if ((current_cond & condition_mask) != 0)
				return current_cond;

			if (timeout > 0)
			{
				if (!end_time_set)
				{
					end_time = System.currentTimeMillis() + timeout;
					end_time_set = true;
				}
				else
				{
					timeout = end_time - System.currentTimeMillis();

					if (timeout <= 0)
						return current_cond | ChannelCondition.TIMEOUT;
				}
			}

			try
			{
				if (timeout > 0)
					c.wait(timeout);
				else
					c.wait();
			}
			catch (InterruptedException e)
			{
			}
		}
	}
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:76,代码来源:ChannelManager.java

示例4: waitForCondition

/**
 * Wait until for a condition.
 * 
 * @param c
 *            Channel
 * @param timeout
 *            in ms, 0 means no timeout.
 * @param condition_mask
 *            minimum event mask
 * @return all current events
 * 
 */
public int waitForCondition(Channel c, long timeout, int condition_mask) {
	long end_time = 0;
	boolean end_time_set = false;

	synchronized (c) {
		while (true) {
			int current_cond = 0;

			int stdoutAvail = c.stdoutWritepos - c.stdoutReadpos;
			int stderrAvail = c.stderrWritepos - c.stderrReadpos;

			if (stdoutAvail > 0)
				current_cond = current_cond | ChannelCondition.STDOUT_DATA;

			if (stderrAvail > 0)
				current_cond = current_cond | ChannelCondition.STDERR_DATA;

			if (c.EOF)
				current_cond = current_cond | ChannelCondition.EOF;

			if (c.getExitStatus() != null)
				current_cond = current_cond | ChannelCondition.EXIT_STATUS;

			if (c.getExitSignal() != null)
				current_cond = current_cond | ChannelCondition.EXIT_SIGNAL;

			if (c.state == Channel.STATE_CLOSED)
				return current_cond | ChannelCondition.CLOSED
						| ChannelCondition.EOF;

			if ((current_cond & condition_mask) != 0)
				return current_cond;

			if (timeout > 0) {
				if (!end_time_set) {
					end_time = System.currentTimeMillis() + timeout;
					end_time_set = true;
				} else {
					timeout = end_time - System.currentTimeMillis();

					if (timeout <= 0)
						return current_cond | ChannelCondition.TIMEOUT;
				}
			}

			try {
				if (timeout > 0)
					c.wait(timeout);
				else
					c.wait();
			} catch (InterruptedException e) {
			}
		}
	}
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:67,代码来源:ChannelManager.java


注:本文中的com.trilead.ssh2.ChannelCondition.STDERR_DATA属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。