2

i tested with zombie and its give this type of error and my app crash many time and show same error.

https://i.stack.imgur.com/KStvf.png

here is my code

- (void)connection:(NSString*)serviceName forIpAddress:(NSString *)ipAddress forPort:(NSString *)portNo{

if(inputStream && outputStream)
    [self close];


NSString *urlString = [NSString stringWithFormat:@"http://%@", ipAddress];
NSURL *website = [NSURL URLWithString:urlString];
if (!website) {
    BFLog(@"%@ is not a valid URL", website);
}
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)[website host], [portNo intValue], &readStream, &writeStream);
CFReadStreamSetProperty(readStream,kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
CFWriteStreamSetProperty(writeStream,kCFStreamPropertyShouldCloseNativeSocket,kCFBooleanTrue);
inputStream = (__bridge NSInputStream *)readStream;
outputStream = (__bridge NSOutputStream *)writeStream;
[self open];
}

open socket

 - (void)open{

[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream open];
[outputStream open];
}

-(void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent{

    case NSStreamEventHasBytesAvailable:
        event = @"NSStreamEventHasBytesAvailable";
        if (theStream == inputStream)
        {
            uint8_t buffer[1024];
            int len;
            while ([inputStream hasBytesAvailable])
            {
                len = (int)[inputStream read:buffer maxLength:1024];
                if (len > 0)
                {
                    NSMutableString *output = [[NSMutableString alloc] initWithBytes:buffer length:len encoding:NSUTF8StringEncoding];
                    if (nil != output)
                    {
                        BFLog(@"Received data--------------------%@", output);
                        BFLog(@"marr delete data..%@",marrDelId);
                        [self deletedata:@""];
                    }
                }
            }
        }
        break;

}

  • Could you please include the code where the error happens? – Fabio Berger Aug 10 '17 at 09:23
  • Welcome to SO. Please take some time to get to know our site, at both the **[tour](https://stackoverflow.com/tour)** and **[help center](https://stackoverflow.com/help)**. So that we can help you with your problem, please provide a **[Minimal, Complete and Verifiable Example](https://stackoverflow.com/help/mcve)**, and explain exactly what your problem is and what steps you have already tried to solve it. – Toastrackenigma Aug 10 '17 at 09:23
  • @FabioBerger : app automatically crash – Bhadresh MindLogic Aug 10 '17 at 09:26
  • @BhadreshMindLogic Do you have a breakpoint for all exceptions? If not add it (Described here: https://stackoverflow.com/questions/17802662/exception-breakpoint-in-xcode) and try again. It will stop at the line which causes the crash. – Fabio Berger Aug 10 '17 at 09:32

0 Answers0