Hello,
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
Now in order to listen on socket for alarms i need to accept the connection but
this will make it blocking. So i have to add it in select() to hear whether it
is ready to be read or not and then accept connection.
I am thinking of doing it in following manner.
Please comment on the following if it is wrong
This code will be main
main()
{
fd_set master;
fd_set read_fds;
int listener;
int fdmax;
int newfd;
FD_ZERO(&master);
FD_ZERO(&read_fds);
listener = socket(AF_INET, SOCK_STREAM, 0);
bind(listener, (struct sockaddr *)&myaddr, sizeof(myaddr));
listen(listener, 10)
// add the listener to the master set
FD_SET(listener, &master);
fdmax = listener;
while()
{
read_fds = master;
snmp_select_info(&numfds, &read_fds, NULL, 0);
select(numfds,&read_fds,0,0,NULL)
if (FD_ISSET(listener , &read_fds))
{
newfd = accept(listener, (struct sockaddr
*)&remoteaddr,&addrlen)
//function1 --->reads the data add it to queue and forward to
manager as a TRAP
}
}
}
But this does'nt seem to work , do i need to register my function1.Please help
me on this
Thanks
-------------------------------------------------------------------------
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-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders