<< Back to man.lupaworld.com

21.        Operational Modes

SNMP++ is designed to support a variety of operational modes. The modes of operation, allow for Graphical User Interface (GUI) and console mode applications to be constructed. GUI operational mode cooperates with the existing GUI event systems while console mode operational mode allows for utilization of a custom event system or no event system at all.

 

21.1.1. Microsoft Windows Event System Operation

For MS-Windows usage, SNMP++ cooperates with the MS-Windows messaging system. Blocked mode calls allow other messages to be processed.

 

21.1.2. Open Systems Foundation (OSF) X11 Motif Operation

The X11 interface is identical to the MS-Windows interface. Both MS-Windows and X11 versions of SNMP++ support blocked and asynchronous modes of usage. One additional function call is required for an X11 application to register its X11 context with SNMP++ in order for SNMP++ to take advantage of X11’s event system. This enables XtAppMainLoop() or similar functions to recognize and dispatch all asynchronous SNMP++ events transparently.

 

·         The context parameter passed in is returned from a call to XtAppInitialize().

·         The return value is zero if the function is successful in registering with X11.

//----------------[ initialize SNMP++ X11 Context ]--------------------------

int SNMPX11Initialize( XtAppContext context);


 

 

 


21.1.3. Non GUI Based Application Operation

A third operational mode for SNMP++ is that for constructing text mode console applications. These types of applications can operate using either blocked mode or asynchronous mode calls. For blocked mode calls, no additional SNMP++ function calls are needed. Asynchronous calls require usage of some event system. For console operational asynchronous mode, SNMP++ offers a set of function calls for reading the currently used file descriptors (socket handles) which the caller may then utilize in their own ‘select’ call. If a SNMP++ file descriptor has a pending event, the caller may invoke a routine to process all pending events.

 

SNMPGetFdSets

Used to determine which file descriptors will potentially be active. The function fills in read, write and exception masks which then can be passed to ‘select’.

//-------[ get file descriptor set from SNMP++ ]------------------------------------

void SNMPGetFdSets( int &maxfds,                           // max # of fds represented

                                      fd_set &read_fds,                 // mask representing read actions

                                      fd_set &write_fds,                 // mask representing write actions

                                      fd_set &exceptfds);                // mask representing exception actions

 

 

 

 

 

 

 

 

 

 

SNMPGetNextTimeout

Used to determine the time the next time-out event will occur. This value can then be used to as the maximum interval that a blocked operation, such as select, should wait before returning control. The time-out calculation is based on the closest time of all user-registered time-outs and SNMP retransmission time-outs.

 

//---------[ Get the next time-out value ]----------------------------------------------------

unsigned long int SNMPGetNextTimeout( );        // returns value in 1/100 of seconds


 

SNMPProcessPendingEvents

Used to process all currently outstanding events. This function may call any callbacks associated with completed time-outs, file descriptors or outstanding SNMP messages. This function does not block, it handles only events outstanding at the time.

 

//------[ process pending events ]----------------------------------------------------------

int SNMPProcessPendingEvents();