GCDAsyncUdpSocketDelegate

Objective-C

@protocol GCDAsyncUdpSocketDelegate
@optional

/**
 * 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.
**/
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didConnectToAddress:(NSData *)address;

/**
 * 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.
**/
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotConnect:(NSError *)error;

/**
 * Called when the datagram with the given tag has been sent.
**/
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didSendDataWithTag:(long)tag;

/**
 * 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.
**/
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotSendDataWithTag:(long)tag dueToError:(NSError *)error;

/**
 * Called when the socket has received the requested datagram.
**/
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data
                                             fromAddress:(NSData *)address
                                       withFilterContext:(id)filterContext;

/**
 * Called when the socket is closed.
**/
- (void)udpSocketDidClose:(GCDAsyncUdpSocket *)sock withError:(NSError *)error;

@end

Swift

protocol GCDAsyncUdpSocketDelegate

Undocumented

    • 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: (any 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: (any 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: (any Error)!)