satish1245 satish1245 - 2 months ago 12
iOS Question

How to disconnect TCP/IP socket connection programmatically?

Is there any way to close socket connection programmatically?,Please help me out if any solution.

Answer
Yes you can disconnect your socket connection

    inputStream.delegate = nil;
    [inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    [inputStream close];
    inputStream = nil;
    isInputStreamOpen = NO;

    outputStream.delegate = nil;
    [outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    [outputStream close];
    outputStream = nil;
    isOutputStreamOpen = NO;

    inputBuffer = nil;
    outputBuffer = nil;
Comments