Need advice about selsocket analogue for a set of sockets
Dmitry Krivenok
krivenok.dmitry at gmail.com
Thu May 13 15:01:22 UTC 2010
Hi Hackers,
I know that FreeBSD-8 kernel provides selsocket function declared as follows:
int selsocket(struct socket *so, int events, struct timeval *tvp,
struct thread *td);
It's very useful if you have just one socket and don't care about
which events fired.
In my case, however, I have an array of the following structures
typedef struct {
struct socket *fd;
int events;
int revents;
} sock_poll_t;
and need to poll all sockets saving results in revents field.
That is I need to implement a function with the following prototype:
int sockets_poll( sock_poll_t * ufds, unsigned int nfds, int timeout_msecs);
Obviously, selsocket is useless is such scenario (it returns 0 on
success and therefore
doesn't tell which events fired).
I looked into sys/kern/sys_generic.c but didn't find any functions
which may be useful
for working with array of structures above.
I could try to implement a function similar to selsocket, but I cannot
use the same helper
functions (selfdalloc, seltdwait, etc) because they are considered as
implementation details
and defined as static.
I need your advice.
What's the best way of solving my problem?
Thanks in advance!
--
Sincerely yours, Dmitry V. Krivenok
e-mail: krivenok.dmitry at gmail.com
skype: krivenok_dmitry
jabber: krivenok_dmitry at jabber.ru
icq: 242-526-443
More information about the freebsd-hackers
mailing list