GCDAsyncUdpSocket cannot bind port on iOS simulator

萝らか妹 提交于 2019-12-24 01:48:13

问题


I'm working on sending message through UDP. However, I've been trapped in the problem about 'binding port'.

When I built the project on iOS simulator first time, nothing strange happened. Everything was fine.

But when I built the project second time. I got an error message from terminal when the app tried to bind port.

The message goes like this "Error Domain=NSPOSIXErrorDomain Code=48 "Address already in use" UserInfo=0x767c830 {NSLocalizedFailureReason=Error in bind() function, NSLocalizedDescription=Address already in use}"

What's confuses me is that the error didn't appear when I run my app on iPad.

I guess that maybe it is for the reason that I didn't close the socket. But why it goes correctly on iPad?

Hope someone could solve this. Thx!


回答1:


Current head of GDAAsyncUdpSocket does not (also) set SO_REUSEPORT (it just does ADDRESS, which is quite enough for TCP).

I just popped in a quick fix:

https://github.com/dirkx/CocoaAsyncSocket/commit/5ec8c83d59ecb754824f706198eb62e29961c1be

https://github.com/dirkx/CocoaAsyncSocket

and it should get fixed upstream too:

https://github.com/robbiehanson/CocoaAsyncSocket/pull/159

Thanks,

Dw.



来源:https://stackoverflow.com/questions/16838513/gcdasyncudpsocket-cannot-bind-port-on-ios-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!