How to callback NSStreamDelegate with NSStreamEventOpenCompleted?

I use with very similar code and it works fine for me.
Try the code below.

   NSString* host = @"192.168.2.105";
    CFReadStreamRef readStream;
    CFWriteStreamRef writeStream;
    UInt32 port = 8008;

    CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (__bridge CFStringRef)(host), port, &readStream, &writeStream);

    if (writeStream && readStream) {

        self.InputStream = (__bridge  NSInputStream *)readStream;
        [self.InputStream setDelegate:self];
        [self.InputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
        [self.InputStream open];

        self.OutputStream = (__bridge  NSOutputStream *)writeStream;
        [self.OutputStream setDelegate:self];
        [self.OutputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
        [self.OutputStream open];
    }

If it doesn’t work for you, I can to send you a small app that implement TCP Client and server for a example.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)