Re: addding new fd in select() for recieving request

[email protected]
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hello Dev,

This means that in main() of my subagent

main()
{
        init_agent("snmpV3Agent");
        init_currentAlarmTable();
        init_snmp("snmpV3Agent");
         ... .
         ........
        //start listning for client
        listener = socket(AF_INET, SOCK_STREAM, 0);
        bind(listener, (struct sockaddr *)&myaddr, sizeof(myaddr));
        listen(listener, 10)

        while()
        {
            snmp_select_info(&numfds, &read_fds, NULL, 0);
            select(numfds,&read_fds,0,0,NULL)
             if (FD_ISSET(listener , &read_fds))
             {
                 //accept when ready to be read
                 newfd = accept(listener, (struct sockaddr *)&remoteaddr,&addrlen)
                 
                  //myfunction1 --->reads the data add it to queue and forward to manager as a TRAP
                 register_readfd(&numfds,(*myfunction1),NULL);
             }
         }

}

or it is just call snmp_select_info() with readfds containing my fd and just call register_readfd() not even check for FD_ISSET(). This will automatically accept the connection when the fd is ready to be read and in the function pointer(call back method) i can write the code to extract the data.

Is it. Please do reply if i am wrong anywhere.


--Thanks a lot



----- Original Message -----
From: Dave Shield <[email protected]>
To: [email protected]
Cc: [email protected]
Sent: Mon, 9 Jun 2008 13:40:40 +0530 (IST)
Subject: Re: addding new fd in select() for recieving request

2008/6/9  <[email protected]>:
> I have a requirement that i also need to listen for alarms coming
> from another application on socket and forward them to manager
> apart from GET/SET request from Manager

Have a look at the 'register_readfd()' routine
which is designed for exactly this purpose.


> I am thinking of doing it in following manner.
> Please comment on the following if it is wrong

You do not need to change the main() code.
The Net-SNMP toolkit already supports the
functionality you require.

Dave



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.