Re: [Q] wait on snmp walk?

Doug Hughes (Doug.Hughes@Eng.Auburn.EDU)
Fri, 20 Jun 1997 16:56:06 -0500

>I'm trying to find a way to have a command executed when an snmp walk is
>completed. For example, I want to be able to write code like this:
>
>>set sess [snmp session -address 1.2.3.4]
>>$sess walk x ipAdEntAddr "printfFunc $x"
>>wait $sess "doNextThing $sess"
>>puts "Working . . ."
>><more code>
>
>Ie, 'snmp walk' is called asynchronously. Then, when it is finished
>'doNextThing' is called. However, while the walk is being done, other code
>can be processed. I know there is an snmp wait command, I just don't know if
>it can do what I want it to do. Can anyone tell me if this can be done and,
>if so, how? I don't have much in the way of sample code, which is my usual
>method for learning how to do things.
>

Huh, I was always under the impression that walk was this way by default.
News to me.. (In fact, I just checked my 2.1.4 executable and it does what
you ask by default by jingo. I keep recompiling 2.1.5 and helping people,
but haven't installed it yet since 2.1.4 works so well and has all my mods. ;)

hmm. maybe it was changed in 2.1.5.. I just have to bite the bullet one
of these days and install it and convert my scripts..

>In addition, I have a question unrelated to scotty. Does anyone know if
>there is a way to put a function on the event queue? I want to be able to
>have a function that takes care of a queue of information. Whenever
>information get's handed to the queue, I want to add an event to the
>'event queue' to run another function that will process whatever is on the
>stack. For example:
>>>proc addQueue item {
>> global theQueue
>>
>> lappend theQueue $item
>> addevent checkQueue
>>}
>
>Thus, when the program gets a chance, it will call the function checkQueue
>to handle any data it contains. I'm sure it can be done, I just don't have
>any idea how.
>

well, fileevent will do this if you change your queue into a channel/descriptor.
(tclx has something similar)

fileevent channelId writable ?script?

Or, you could do this cruedly with a self-referencing after script.

after 300 addQueue

proc addQueue item {
global theQueue

if {[llength $TheQueue] > 1} {
lappend theQueue $item
addevent checkQueue
}
after 300 addQueue
}

A brief man -k shows some possibly useful man pages:

Tk_ServiceEvent Tk_QueueEvent (3) - add events to the Tk event queue and invoke event or idle handlers
Tcl_WatchFile Tcl_CreateEventSource (3) - Event sources, the event notifier, and the event queue
Tcl_WaitForEvent Tcl_CreateEventSource (3) - Event sources, the event notifier, and the event queue

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.