<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE>.hmmessage P {
        PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px
}
BODY.hmmessage {
        FONT-SIZE: 10pt; FONT-FAMILY: Tahoma
}
</STYLE>
<META content="MSHTML 6.00.6000.16544" name=GENERATOR></HEAD>
<BODY class=hmmessage bgColor=#ffffff>
<DIV><FONT face="Courier New">Unfortunately you cannot obtain a file descriptor
you can wait on with WinPcap. There's simply no file descriptor. As far as
WinPcap is concerned, you can only obtain a win32 HANDLE with pcap_getevent()
and wait on it with WaitForSingleObject/MultipleObjects(Ex). Can you obtain a
wait HANDLE from a socket handle?</FONT></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV><FONT face="Courier New">Have a nice day</FONT></DIV>
<DIV><FONT face="Courier New">GV</FONT></DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=sagarwal10@hotmail.com href="mailto:sagarwal10@hotmail.com">S A</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=winpcap-users@winpcap.org
href="mailto:winpcap-users@winpcap.org">winpcap-users@winpcap.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, December 12, 2007 11:18
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Winpcap-users] How to combine
pcap_next_ex with poll/select incygwin</DIV>
<DIV><BR></DIV>Hi all<BR> <BR>My question is about trying to
figure out how to use winpcap and poll ()/select ()
together
in a cygwin environment.<BR> <BR>The Linux program I'm
trying to port, waits for a telnet connection to establish a connection
to a <BR>user on a local port number (i.e. localhost). The user can then
choose to send/receive raw packets <BR>(of any ethernet type - hence the need
for raw sockets via winpcap) on any of the network devices <BR>on the machine.
<BR><BR>My dilemma is how to make the poll/select call i use (to wait for an
incoming telnet connection<BR>and further interaction with the user) and
combine it with using pcap_next_ex() to receive<BR>raw packets.<BR><BR>I know
very little of windows but I understand both winpcap & cygwin poll
(winsup/cygwin/select.cc<BR>right?) use a call "WaitForMultipleObjects ()" to
sleep and wait for new receive events. Is there a way<BR>I can translate a
winpcap socket pcap_t handle into an fd that I could pass to the poll/select
fd list?<BR>Or vice versa - translate cygwin fd's into pcap
handles?<BR><BR>(Although the brief browsing I did in the winpcap sources I
only saw a call to WaitForSingleObject() though)<BR><BR>My only other options
(none of which I like) are:<BR><BR>1. Use threads. Multiple processes won't
work because the telnet program and the raw socket<BR> program
would have to interact with each other - and wouldn't that mean more localhost
connections<BR> unless I use some kind of proc or ioctl
interface?<BR><BR>2. Use winpcap to also receive IP packets and thus handle
the telnet protocol in my program.<BR> However this is
unnnecessarily complex and I don't even see the
pcap_findalldevs<BR> presenting me with a localhost device
(i.e. the equivalent of the "loopback" or "lo" netdev in linux).<BR><BR>3. Use
a maximum wait time on both the poll call and the pcap_next_ex call. I'm
afraid my<BR> program will get sluggish and also eat up a
lot of CPU cycles.<BR><BR>Any recommendations on what to do or more code to
look at are greatly welcomed. Thanks!<BR>And thanks for all the great open
source work.<BR><BR><BR>
<HR>
Don't get caught with egg on your face. Play Chicktionary! <A
href="http://club.live.com/chicktionary.aspx?icid=chick_wlhmtextlink1_dec"
target=_new>Check it out!</A>
<P>
<HR>
<P></P>_______________________________________________<BR>Winpcap-users
mailing
list<BR>Winpcap-users@winpcap.org<BR>https://www.winpcap.org/mailman/listinfo/winpcap-users<BR></BLOCKQUOTE></BODY></HTML>