getting didConnectToHost when using connect(toAddress:)

53 views
Skip to first unread message

Ringo Wathelet

unread,
Aug 28, 2018, 2:00:04 AM8/28/18
to CocoaAsyncSocket
I'm just staring with GCDAsyncSocket using swift in IOS, all is working well, however, 
I have some code like this:

    mySocket = GCDAsyncSocket(delegate: self, delegateQueue: DispatchQueue.main)
   
try mySocket.connect(toAddress: address)

   
// this is the one getting called
   
@objc func socket(_ sock: GCDAsyncSocket, didConnectToHost host: String, port: UInt16) {
       
print("--->  didConnectToHost host: \(host)  port: \(port) ")
   
}
   
   
@objc func socket(_ sock: GCDAsyncSocket, didConnectToAddress address: Data) {
       
print("---> didConnectToAddress ")
   
}

I was expecting the "didConnectToAddress" to be called but I get "didConnectToHost".
Is this normal?

Arno Gramatke

unread,
Aug 28, 2018, 2:38:55 AM8/28/18
to cocoaasy...@googlegroups.com
I would consider this to be correct. There is no delegate method socket:didConnectToAddress: in GCDAsyncSocket, only socket:didConnectToHost:port and socket:didConnectToUrl:.

GCDAsyncUdpSocket has socket:didConnectToAddress:, though. Maybe a mix up?

--
You received this message because you are subscribed to the Google Groups "CocoaAsyncSocket" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocoaasyncsock...@googlegroups.com.
To post to this group, send email to cocoaasy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cocoaasyncsocket/542706c5-95ef-42f5-93f6-8cd8e8284e80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ringo Wathelet

unread,
Aug 28, 2018, 3:56:49 AM8/28/18
to CocoaAsyncSocket

Thanks, you are correct. I don't know where I got socket:didConnectToAddress from.
Seams like a good idea at the time, since it's not easy to find GCDAsyncSocket documentation in swift.
Reply all
Reply to author
Forward
0 new messages