while(1) block my recv thread
- by zp26
Hello.
I have a problem with this code.
As you can see a launch with an internal thread recv so that the program is blocked pending a given but will continue its execution, leaving the task to lock the thread.
My program would continue to receive the recv data socket new_sd and so I entered an infinite loop (the commented code).
The problem is that by entering the while (1) my program block before recv, but not inserting it correctly receives a string, but after that stop.
Someone could help me make my recv always waiting for information?
Thanks in advance for your help.
-(IBAction)Chat{
[NSThread detachNewThreadSelector:@selector(riceviDatiServer) toTarget:self withObject:nil];
}
-(void)riceviDatiServer{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
labelRicevuti.text = [[NSString alloc] initWithFormat:@"In attesa di ricevere i dati"];
char datiRicevuti[500];
int ricevuti;
//while(1){
ricevuti = recv(new_sd, &datiRicevuti, 500, 0);
labelRicevuti.text = [[NSString alloc] initWithFormat:@"%s", datiRicevuti];
//}
[pool release];
}