hi
i am writing a small C program in linux that is using the qt library for GUI development but it seems that my socket call is hanging the GUI and not letting it update.

It updates does only after it gets all the 20 IP(s) in list though all this is done in a seperate thread

(while(i<20))
{
socket calls //using iotctl(FIONBIO) calls here
retrieve the IPs
fille the GUI list
}

it's not blocking as it is recursing and returning -1 from recv for those sockets which has no data.
but it's not letting hold the list view to update, only when the 20 loops are recursed the list view is update.

all this is done in a seperate thread . any pointers as to how can i do a synchronous I/O so that my thread could be called only when there is a recv to be done .


anypointer please .

cheers
Rohit








#include "thread.h"

void mythread::run()
{
//signal(SIGIO,sigio_func);
//fcntl(0,F_SETOWN,getpid());
//fcntl(0,F_SETFL,FASYNC);

int i=0;
//while(i<2)
{

int sock,bytes_rec,fromlen,block;
char buffer[65535];
struct sockaddr_in from;
struct ip* ipheader;
struct tcphdr *tcpheader;
char * buf;
block=1;
sock = socket(AF_INET,SOCK_RAW,IPPROTO_TCP );
while(i<20)
{

ioctl(sock,FIONBIO,(char *)&block);
sigblock(sigmask(SIGIO));
while(sigflag=0)
sigpause(0);

i++;
fromlen=sizeof(from);
bytes_rec = recv(sock,buffer,sizeof(buffer),0);
ipheader=(struct ip*)buffer;
tcpheader = ( struct tcphdr *)(buffer + (ipheader->ip_hl));

QString label1=inet_ntoa(ipheader->ip_src);

QListViewItem * item = new QListViewItem(tview,label1);
tview->insertItem(item);
sigflag=0;
sigsetmask(0);
}


}

}