<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hi all<br>&nbsp;&nbsp; <br>My question is about trying to figure out how to use winpcap and poll ()/select () together&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in a cygwin environment.<br>&nbsp;&nbsp;&nbsp; <br>The Linux program I'm trying to port, waits for a telnet connection to establish&nbsp; 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 &amp; 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>&nbsp;&nbsp; program would have to interact with each other - and wouldn't that mean more localhost connections<br>&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; However this is unnnecessarily complex and I don't even see the pcap_findalldevs<br>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; 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 />Share life as it happens with the new Windows Live. <a href='http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_122007' target='_new'>Share now!</a></body>
</html>