GCDAsyncUdpSocketDelegate

@protocol GCDAsyncUdpSocketDelegate

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    • By design, UDP is a connectionless protocol, and connecting is not needed.
    • However, you may optionally choose to connect to a particular host for reasons
    • outlined in the documentation for the various connect methods listed above.
    • This method is called if one of the connect methods are invoked, and the connection is successful.

    Declaration

    Objective-C

    - (void)udpSocket:(GCDAsyncUdpSocket *)sock
        didConnectToAddress:(NSData *)address;

    Swift

    optional func udpSocket(_ sock: GCDAsyncUdpSocket!, didConnectToAddress address: Data!)
    • By design, UDP is a connectionless protocol, and connecting is not needed.
    • However, you may optionally choose to connect to a particular host for reasons
    • outlined in the documentation for the various connect methods listed above.
    • This method is called if one of the connect methods are invoked, and the connection fails.
    • This may happen, for example, if a domain name is given for the host and the domain name is unable to be resolved.

    Declaration

    Objective-C

    - (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotConnect:(NSError *)error;

    Swift

    optional func udpSocket(_ sock: GCDAsyncUdpSocket!, didNotConnect error: Error!)
    • Called when the datagram with the given tag has been sent.

    Declaration

    Objective-C

    - (void)udpSocket:(GCDAsyncUdpSocket *)sock didSendDataWithTag:(long)tag;

    Swift

    optional func udpSocket(_ sock: GCDAsyncUdpSocket!, didSendDataWithTag tag: Int)
    • Called if an error occurs while trying to send a datagram.
    • This could be due to a timeout, or something more serious such as the data being too large to fit in a sigle packet.

    Declaration

    Objective-C

    - (void)udpSocket:(GCDAsyncUdpSocket *)sock
        didNotSendDataWithTag:(long)tag
                   dueToError:(NSError *)error;

    Swift

    optional func udpSocket(_ sock: GCDAsyncUdpSocket!, didNotSendDataWithTag tag: Int, dueToError error: Error!)
    • Called when the socket has received the requested datagram.

    Declaration

    Objective-C

    - (void)udpSocket:(GCDAsyncUdpSocket *)sock
           didReceiveData:(NSData *)data
              fromAddress:(NSData *)address
        withFilterContext:(id)filterContext;

    Swift

    optional func udpSocket(_ sock: GCDAsyncUdpSocket!, didReceive data: Data!, fromAddress address: Data!, withFilterContext filterContext: Any!)
    • Called when the socket is closed.

    Declaration

    Objective-C

    - (void)udpSocketDidClose:(GCDAsyncUdpSocket *)sock withError:(NSError *)error;

    Swift

    optional func udpSocketDidClose(_ sock: GCDAsyncUdpSocket!, withError error: Error!)