ios - CocoaAsyncSocket不是基于线程的吧?为什么我alloc了很多socket就出现了很多的新线程
PHP中文网
PHP中文网 2017-04-17 13:04:26
0
1
367

我要做的是扫描局域网内的每一个ip XX端口是否开放
一开始尝试过开200多个socket
分别connectto host
结果调试的时候发现有200多个线程在运行

CocoaAsyncSocket不是号称基于NSRunLoop的吗?

求指教,这种扫端口的形式怎么样能最快最可靠的完成

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
PHPzhong

Based on NSRunLoop means that the callback function will run on the main thread through this mechanism during callback, ensuring that there will be no cross-thread calling problems. But its bottom layer is still implemented using threads, so many threads will be created.

If you are scanning ports and opening so many threads will not cause the system to freeze or anything, just use it as it is. There is probably no optimization worth doing.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template