HI there, i got a problem with the following code. Hope someone can help me..

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. Is there a way i can solve the problem ? My 
primary objective is to fetch new data whenever there is data sent over the 
server.

I was thinking instead of keep looping the function and rerun the code to check 
for new data, is there another way of doing it? so the line "length = 
recvfrom(s, buffer, ETH_FRAME_LEN, 0, NULL, NULL)" wont have to run repeatedly 
for every 1.0s.



int main()
{ //****coding of a window that include some buttons;***

  //when button "chart" is press by user, a bar chart will be shown using 
callback

 //other buttons include pause, update etc...

}

//functions


Chart (Fl_Widget* , void*)
{
//I declared my buffer as global variables.

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);
//every 0.5s , the function Chart will be recall. Looping the function every 
0.5s.
//Each time it loop, it will fetch new data if there is data sent via the 
server.
}


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

Reply via email to