> The line "length = recvfrom(s, buffer, ETH_FRAME_LEN, 0, NULL, NULL)"
> seem to slow down my program. Whenever the program is run, my button
> like pause and update will not be very responsive.
> ...
> Chart (Fl_Widget* , void*)
> {
>   unsigned char dest_mac[6] = {0x32, 0x31, 0xA5, 0x5A, 0x31, 0x32};
>   unsigned char src_mac[6] = {0x32, 0x75, 0xA5, 0x5A, 0x31, 0x81};
>   s= socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
>   length = recvfrom(s, buffer, ETH_FRAME_LEN, 0, NULL, NULL);
>   Fl::repeat_timeout(0.5, callback1);
> }

In general you should never wait for data from sockets or pipes directly
because your program is likely to block until data becomes available.

[Under Unix] you can use the Fl::add_fd function so that your pipe or
socket can be handled via the main event loop so GUI processing can still
continue while waiting for data. See the docs, and Greg's Cheat Sheet:
http://www.fltk.org/documentation.php/doc-1.1/Fl.html#Fl.add_fd
http://seriss.com/people/erco/fltk/#add_fd

Otherwise you may need to handle the socket processing in a child
thread, but that raises all sorts of issues of its own. See
http://www.fltk.org/documentation.php/doc-1.1/advanced.html#advanced

Good luck
D.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to