2

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!

BuG.BS
  • 95
  • 1
  • 8
  • Seeing same here; it is UDP specific; despite SO_REUSE set in GCDAAsyncUdpSocket. And 'netstat -na' confirms the port is bound; and 'lsof' confirms it is no longer owned by a process. Resetting firewall and interfaces does not help. – Dirk-Willem van Gulik Jun 01 '13 at 08:25

1 Answers1

3

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.

Dirk-Willem van Gulik
  • 7,566
  • 2
  • 35
  • 40