Re: g_io_channel_win32_poll() Problem on Windows

On 7/27/2017 2:56 PM, LRN wrote:
On 7/27/2017 2:06 PM, Faik wrote:

As you might guess, in  arv_gv_discover_socket_list_new() function,  GPollFDs
are created and in _discover() function, a broadcast message is sent and then
 polled for reply. but no luck, still in _discover(), it time outs.  By the
way, in Linux, the same application works smootly.
I also checked the discovery packet was actually emitted, and I saw a camera
discovery ack packet coming to my network adapter via WireShark.
Portable I/O is tricky. If i were in your place, i would write the simplest
possible code that does this thing (creates a socket, sends a broadcast
message, then waits for a reply) using W32 socket API only. Once *that* works,
figure out what glib is doing differently. Since you're providing the socket
object to glib, at least socket creation part is already in your hands. IIRC,
glib calls WSACreateEvent() to create an event handle, then binds it to the
socket using WSAEventSelect(), then just waits on the event handle using
conventional WaitForMultipleObjects...() (in your case WaitForSingleObject
would probably be enough). Once it indicates that the event is set, glib calls
WSAEnumNetworkEvents () to see which socket events happened.

After trying this myself (for unrelated reasons), i found that *only*
giochannel GSource does WSAEventSelect() on a socket event (in
g_io_win32_prepare()) to bind it to an event handle, which can then be polled.
If you are not using a main loop (and GSource), then this doesn't happen, and
the events you feed to g_poll() are completely inert.

Thus, apart from creating sockets yourself, you should also call call
WSAEventSelect(). It might be possible to offload this to glib by pretending to
be a main loop, but driving stuff manually, but i haven't checked that yet.

O< ascii ribbon - stop html email! -

Attachment: 0x6759BA74.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]