开发者

PHP Using ssh2_shell() with socket_select()

I'm using php to open an ssh session.

e.g.:

$stream = ssh2_shell($connectio开发者_JAVA百科n, 'vt102', null, 80, 24, SSH2_TERM_UNIT_CHARS);

I can read the stream with:

$content=stream_get_contents($stream);

In order to monitor the stream I want to connect it to a socket. So that I can use socket_select()

Is this even possible?


No - ssh is a layer of protocol on top of a socket - you can't inject code between the layers) but socket_select operates at the socket layer.

But in PHP there is an additional layer on top of the ssh layer - the stream - and you can use stream_select() on a set of streams (which can include stuff other than ssh)


You could use phpseclib, a pure PHP SSH implementation, and then do stream_select($ssh->fsock) or socket_select($ssh->fsock).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜