FW: Combining winpcap packet wait with poll/select in cygwin
Fri Dec 14 01:28:00 GMT 2007
(I've tried this question on the winpcap-users list already with no luck).
Summary: Has anyone tried to have events (POLL_IN/POLL_OUT) on regular
fd descriptors combined with winpcap packet receive handles incorporated
into the same sleep event (i.e. poll/select)?
The Linux program I'm trying to port to cygwin, waits for a user to establish a telnet connection
on a local port number (i.e. localhost). The user can then choose to send/receive raw packets
(of any ethernet type - hence the need for raw sockets via winpcap) on any of the network devices
on the machine.
My dilemma is how to make the poll/select call i use (to wait for an incoming telnet connection
and further interaction with the user) and combine it with using pcap_next_ex() to receive
I know very little of windows but I understand both winpcap & cygwin poll (winsup/cygwin/select.cc
right?) use a call "WaitForMultipleObjects ()" to sleep and wait for new receive events. I've seen
some of the code in select.cc but is there an easy way to translate the fd's into the HANDLE w4 array
so I can somehow combine it with the winpcap HANDLE)? Or anybody have any experience doing this?
My only other options (none of which I like) are:
1. Use threads. Multiple processes won't work because the telnet program and the raw socket
program would have to interact with each other - and wouldn't that mean more localhost connections
unless I use some kind of proc or ioctl interface?
2. Use winpcap to also receive IP packets and thus handle the telnet protocol in my program.
However this is unnnecessarily complex.
3. Use a maximum wait time on both the poll() call and the pcap_next_ex() call and alternate
checking between the two. I'm afraid my program will get sluggish and also eat up a lot of CPU cycles.
Any recommendations on what to do or more code to look at are greatly welcomed. Thanks!
i’m is proud to present Cause Effect, a series about real people making a difference.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
More information about the Cygwin