Sorry that my question is not directly related to iphone.
Ok I finally got the socket on iphone to connect to my server and send messages , but it can't receilve any messages. The recv function returns -1
What does -1 mean?
Code:
- (void) Receive
{
NSThread *myThread=[[NSThread alloc]initWithTarget:self
selector:@selector(ReceiveOperation)
object:nil];
[myThread start];
[myThread release];
}
- (void) ReceiveOperation
{
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
char buffer[512];
int bytesReceived = recv(_socket, buffer, sizeof(buffer), MSG_OOB);
if (bytesReceived > 0)
{
printf("%s\n", [@"recv bytes" UTF8String]);
}
//buffer= NULL;
NSThread *myThread=[[NSThread alloc]initWithTarget:self
selector:@selector(ReceiveOperation)
object:nil];
[myThread start];
[myThread release];
[pool release];
}
Does my code look fine?
Thanks You