Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top