X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Fri, 14 Dec 2007 09:03:32 -0600
From: Brian Ford <Brian.Ford@FlightSafety.com>
Reply-To: cygwin@cygwin.com
To: cygwin@cygwin.com
Subject: Re: FW: Combining winpcap packet wait with poll/select in cygwin
In-Reply-To: <BAY128-W1624A8046E37E24A3CBB39D2670@phx.gbl>
Message-ID: <Pine.CYG.4.58.0712140843520.3644@PC1163-8460-XP.flightsafety.com>
References: <BAY128-W1624A8046E37E24A3CBB39D2670@phx.gbl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Thu, 13 Dec 2007, S A wrote:

> 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)?

No, I haven't tried because it looked too fragile if it even works, and
Cygwin's poll/select (or the preamble to read/recv; I'm not sure yet) was
causing significant packet reception jitter in my real time application.

> 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)?

You could try get_osfhandle, but I'd suggest going the other way around by
using Cygwin's cygwin_attach_handle_to_fd.  I don't know if it will work
for you, but this might get you an fd that you can use in poll/select for
the winpcap handle.

> My only other options (none of which I like) are:
>
> 1. Use threads.

I went this route and it worked out well for me, but my application was
already threaded, and it didn't have this kind of interaction.

> 2. Use winpcap to also receive IP packets and thus handle the telnet
> protocol in my program. However this is unnnecessarily complex.

Why did you choose this strange localhost telnet IPC to begin with?
Couldn't it just be a library?  I guess it might be because of privilege
issues?

> Any recommendations on what to do or more code to look at are greatly
> welcomed. Thanks!

I would appreciate you letting us know how it turns out.

-- 
Brian Ford
Lead Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained crew...

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

