0

Am using below mentioned code for receiving data from the server by using socket programming. but receiving is not working here.but server connection and sending data are working fine.How to receive data from server.

       case NSStreamEventHasBytesAvailable:
                event = @"NSStreamEventHasBytesAvailable";
                if (theStream == inputStream)
                {
                    uint8_t buffer[1024];
                    int len;
                    while ([inputStream hasBytesAvailable])
                    {
                        len = [inputStream read:buffer maxLength:1024];
                        NSLog(@"buffer %s",buffer);
                         NSLog(@"Received data--------------------%d", len);
                        if (len >= 0)
                        {
                            NSMutableString *output = [[NSMutableString alloc] initWithBytes:buffer length:len encoding:NSUTF8StringEncoding];
                            NSLog(@"Received data--------------------%@", [output description]);
                             NSLog(@"buffer %s",buffer);
                        }
                    }
                }

0 Answers0