Date: Thu, 13 May 2010 19:01:20 +0400 From: Dmitry Krivenok <krivenok.dmitry@gmail.com> To: freebsd-hackers@freebsd.org Subject: Need advice about selsocket analogue for a set of sockets Message-ID: <AANLkTikBmiPzN0qGbSiMVQU1LcLnuTIjZUJts_WsnLyS@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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@gmail.com
skype: krivenok_dmitry
jabber: krivenok_dmitry@jabber.ru
icq: 242-526-443
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikBmiPzN0qGbSiMVQU1LcLnuTIjZUJts_WsnLyS>
