Sha256: 159551199299ca693c79885707518bdb63b8a658f493e7bb7874ea25a2e54362

Contents?: true

Size: 1.16 KB

Versions: 15

Compression:

Stored size: 1.16 KB

Contents

Because a session may be composed of multiple simultaneously operating channels, the Net::SSH interface works by means of _callbacks_. You specify actions that need to occur in response to various events, and when those events occur, the framework invokes the corresonding callbacks.

In order to allow the events to be processed in a continuous manner, you need to be sure to call the @loop@ method of your session handle, after setting up any callbacks that you want to be executed. If you do not call the @loop@ method, your session will terminate as soon as the block is exited, which means none of your carefully laid callbacks will ever be called.

The @loop@ method is easy to invoke:

{{{lang=ruby,caption=Session#loop,number=true
Net::SSH.start( 'host' ) do |session|
  ...
  session.loop
end
}}}

Incidentally, the @loop@ method accepts an optional block, which if specified should return a "false" value when the loop should terminate. In the absense of a block, the loop will continue until there are no more open channels.  Sometimes, however, you only want the loop to continue until some action occurs, at which time you then do some processing and then start the loop again.

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
net-ssh-1.0.1 doc/manual/parts/0011.txt
net-ssh-1.0.10 doc/manual/parts/0011.txt
net-ssh-1.0.2 doc/manual/parts/0011.txt
net-ssh-1.0.9 doc/manual/parts/0011.txt
net-ssh-1.0.4 doc/manual/parts/0011.txt
net-ssh-1.0.7 doc/manual/parts/0011.txt
net-ssh-1.0.3 doc/manual/parts/0011.txt
net-ssh-1.0.5 doc/manual/parts/0011.txt
net-ssh-1.0.6 doc/manual/parts/0011.txt
net-ssh-1.0.8 doc/manual/parts/0011.txt
net-ssh-1.1.2 doc/manual/parts/0011.txt
net-ssh-1.1.1 doc/manual/parts/0011.txt
net-ssh-1.1.0 doc/manual/parts/0011.txt
net-ssh-1.1.4 doc/manual/parts/0011.txt
net-ssh-1.1.3 doc/manual/parts/0011.txt