如何以编程方式断开TCP / IP套接字连接?

时间:2016-09-04 10:05:49

标签: ios objective-c iphone

有没有办法以编程方式关闭套接字连接?如果有任何解决方案,请帮帮我。

1 个答案:

答案 0 :(得分:1)

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;