I'm writing some code using ORBit and glib. I'm trying to receive SNMP traps over UDP sockets, however when I try to add a watch on my socket with g_io_add_watch, my callback never gets called.
Here's what I've got:
udp = getprotobyname("udp");
s = socket(PF_INET, SOCK_DGRAM, udp->p_proto);
if (s < 0)
printf("Failed to open socket.\n");
sa.sin_family=AF_INET; sa.sin_addr.s_addr = htonl(INADDR_ANY); sa.sin_port = htons(162);
if (bind(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { printf("Can't bind local SNMP port!\n"); return; } channel = g_io_channel_unix_new(s); g_io_add_watch(channel, G_IO_IN, myfunc, myuserdata);
Now, myfunc never gets called, yet in netstat, I can see the socket listening and with data in the receive q.
Any ideas? Have I missed something obvious? glib is 2.2.1, in case this is a known bug.
Cheers, Chris.