Re: addding new fd in select() for recieving request
"Dave Shield" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
2008/6/9 <[email protected]>: > main() > { > //start listning for client > listener = socket(AF_INET, SOCK_STREAM, 0); > bind(listener, (struct sockaddr *)&myaddr, sizeof(myaddr)); > listen(listener, 10) This is also where you would register this external socket: register_readfd( listener, listener_callback ); > while() > { Remember to clear the readfd array: numfds = 0; FD_ZERO(&read_fds); and you're not passing in the timeout handling structures. block = 0; > snmp_select_info(&numfds, &read_fds, tvp, &block); You also need to do the same for the external sockets: netsnmp_external_event_info(numfds,&read_fds,NULL,NULL) You probably do need to pass the 'tvp' parameter to select, as well as taking note of the return value: > count = select(numfds,&read_fds,0,0, tvp) The next bit isn't needed. Replace it with: netsnmp_dispatch_external_events( &count, &read_fds, NULL, NULL); That handles checking whether your socket has anything waiting, and calls the registered callback. This should then be followed by if ( count > 0 ) snmp_read( &read_fds ); to handle "normal" SNMP traffic. > } See the main driving loop ("receive()") of snmpd.c for the model of this code. Dave PS: Please do *NOT* repost your query, just because you didn't get a response immediately. Some of us have real work to do, and can't spend all our time providing free advice to impatient programmers! ------------------------------------------------------------------------- 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