g_io_channel_win32_poll() Problem on Windows

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

g_io_channel_win32_poll() Problem on Windows

Faik
Hi,
I am trying to port a Linux application to Windows that highly depends on GLib. I compiled GLib with MSVC 2015. The application uses g_poll() in a place.  In g_poll() GNOME documentation, it states that
If you need to use g_poll() in code that has to run on Windows, the easiest solution is to construct all of your  GPollFDswith  g_io_channel_win32_make _pollfd().

I will provide some small code segments to provide you insight:

                                               .
                                               .
//  In arv_gv_discover_socket_list_new() function            
#ifdef _WIN32
        GIOChannel * channel = g_io_channel_win32_new_socket (discover_socket->socket);
        g_io_channel_win32_make_pollfd(channel,G_IO_IN,&socket_list->poll_fds[i]);
#else
        socket_list->poll_fds[i].fd = g_socket_get_fd (discover_socket->socket);
        socket_list->poll_fds[i].events =  G_IO_IN;
        socket_list->poll_fds[i].revents = 0;
#endif                                          .

                                               .


// In _discover() function
                                               .
                                               .
                                                                                
    arv_gv_discover_socket_list_send_discover_packet (socket_list);  

    do {
#ifdef _WIN32
// g_io_channel_win32_make _pollfd() documentation says call this
        if (g_io_channel_win32_poll(socket_list->poll_fds, socket_list->n_sockets, ARV_GV_INTERFACE_DISCOVERY_TIMEOUT_MS) == 0)  
#else
        if (g_poll(socket_list->poll_fds, socket_list->n_sockets, ARV_GV_INTERFACE_DISCOVERY_TIMEOUT_MS) == 0)       
#endif        
        {
            arv_gv_discover_socket_list_free (socket_list);
            return NULL;
        }

                                               .
                                               .

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.
Since I am newbie to GLib, I cannot be sure if this modification is incorrect or GLib implementation is incorrect. Can you help me to resolve the problem?

Thanks.

PS: The Linux project is Aravis 0.5.9.  (http://ftp.gnome.org/pub/GNOME/sources/aravis/0.5/)


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
LRN
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: g_io_channel_win32_poll() Problem on Windows

LRN
On 8/2/2017 7:37 PM, LRN wrote:

> On 7/27/2017 1:51 PM, mualloc . wrote:
>> arv_gv_discover_socket_list_send_discover_packet(socket_list);
>>
>>
>> do{
>>
>> #ifdef_WIN32
>>
>> // g_io_channel_win32_make _pollfd() documentation says call this
>>
>> if(g_io_channel_win32_poll(socket_list->poll_fds,socket_list->n_sockets,ARV_GV_INTERFACE_DISCOVERY_TIMEOUT_MS)==0)
>>
>>
>> #else
>>
>> if(g_poll(socket_list->poll_fds,socket_list->n_sockets,ARV_GV_INTERFACE_DISCOVERY_TIMEOUT_MS)==0)
>>
>> #endif
>>
>

I recently committed a W32 g_poll() test to glib git master. You can find it
here[1].
If you look closely, you'll realize that g_poll() does almost nothing - it's
just a glorified WaitForMultipleObjectsEx(). All the magic happens in GSource
implementation, and that's what you must use, unless you're willing to do what
i did in that test and do all the pre- and post-processing yourself. Note that
i omitted a lot of corner cases in the test though.

[1]
https://git.gnome.org/browse/glib/commit/?id=425a9f5864f69f804f11279b558ff925d421b546


--
O< ascii ribbon - stop html email! - http://arc.pasp.de/
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Loading...