GCDAsyncUdpSocket无法绑定iOS模拟器上的端口 [英] GCDAsyncUdpSocket cannot bind port on iOS simulator

查看:162
本文介绍了GCDAsyncUdpSocket无法绑定iOS模拟器上的端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过UDP发送消息.但是,我一直被困在绑定端口"的问题上.

当我第一次在iOS模拟器上构建项目时,没有任何奇怪的事情发生.一切都很好.

但是当我第二次建立项目时.当应用尝试绑定端口时,我从终端收到一条错误消息.

消息如下:错误域= NSPOSIXErrorDomain代码= 48地址已在使用中" UserInfo = 0x767c830 {NSLocalizedFailureReason = bind()函数中的错误,NSLocalizedDescription =地址已在使用中}"

让我感到困惑的是,当我在iPad上运行我的应用程序时,没有出现该错误.

我猜可能是因为我没有关闭插座.但是为什么它可以在iPad上正常运行?

希望有人可以解决这个问题.谢谢!

解决方案

当前GDAAsyncUdpSocket头未设置SO_REUSEPORT(它只是设置了ADDRESS,对于TCP来说已经足够了).

我刚刚弹出了一个快速修复方法:

https://github.com/dirkx/CocoaAsyncSocket/commit/5ec8c83d59ecb754824f706198eb62e299611/p>

https://github.com/dirkx/CocoaAsyncSocket

,它也应该固定在上游:

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

谢谢

Dw.

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!

解决方案

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.

这篇关于GCDAsyncUdpSocket无法绑定iOS模拟器上的端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆