Note that there are some explanatory texts on larger screens.

plurals
  1. POGCDAsyncUdpSocket immediately closes when sending to an IPv6 address
    primarykey
    data
    text
    <p>I'm connecting via UDP to a server on a different device which is advertised by Bonjour. When both the iOS device which this code is running on, and the server, are on our wifi network it works just fine because the bonjour service resolves to a 192.168.0.xxx address which our dhcp server hands out. However when it is advertised by bluetooth, sometimes the service resolves to 169.254.xxx.xxx (IPv4) in which case it works just fine. But sometimes it resolves to fe80::xxxx:xxxx:xxxx:xxxx (IPv6) in which case the socket connects (I receive the <code>udpSocket:didConnectToAddress</code> callback) but immediately closes when I try sending data (I receive the <code>udpSocketDidClose:withError</code> callback immediately upon calling send). </p> <pre><code>- (BOOL) setupConnection: (DNSSDService*) service { NSString *host = [service resolvedHost]; NSUInteger port = [service resolvedPort]; NSLog(@"in setupConnection: host %@ port %u", host, port); self.sock = [[GCDAsyncUdpSocket alloc]initWithDelegate:self delegateQueue:dispatch_get_main_queue() ]; NSError *err = nil; if (![self.sock connectToHost:host onPort:port error:&amp;err]) { NSLog(@"we goofed: %@", err); return NO; } return YES; } </code></pre> <p>My <code>udpSocket:didConnectToAddress</code> method calls a send, and my other callbacks are basically just informational (NSLog) at this point. This is the NSError passed to <code>udpSocketDidClose:withError</code>:</p> <pre><code>Error Domain=GCDAsyncUdpSocketErrorDomain Code=4 "Socket closed" UserInfo=0x2630c0 {NSLocalizedDescription=Socket closed} </code></pre> <p>Less than useful.</p> <p>In fixing this I'd like to make it work with IPv6 instead of force IPv4... forcing IPv4 just seems fragile to me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload