|
13 | 13 | #import <Security/SecureTransport.h>
|
14 | 14 | #import <dispatch/dispatch.h>
|
15 | 15 |
|
| 16 | +#include <sys/socket.h> // AF_INET, AF_INET6 |
| 17 | + |
16 | 18 | @class GCDAsyncReadPacket;
|
17 | 19 | @class GCDAsyncWritePacket;
|
18 | 20 | @class GCDAsyncSocketPreBuffer;
|
@@ -930,13 +932,33 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
930 | 932 |
|
931 | 933 | #pragma mark Utilities
|
932 | 934 |
|
| 935 | +/** |
| 936 | + * The address lookup utility used by the class. |
| 937 | + * This method is synchronous, so it's recommended you use it on a background thread/queue. |
| 938 | + * |
| 939 | + * The special strings "localhost" and "loopback" return the loopback address for IPv4 and IPv6. |
| 940 | + * |
| 941 | + * @returns |
| 942 | + * A mutable array with all IPv4 and IPv6 addresses returned by getaddrinfo. |
| 943 | + * The addresses are specifically for TCP connections. |
| 944 | + * You can filter the addresses, if needed, using the other utility methods provided by the class. |
| 945 | +**/ |
| 946 | ++ (NSMutableArray *)lookupHost:(NSString *)host port:(uint16_t)port error:(NSError **)errPtr; |
| 947 | + |
933 | 948 | /**
|
934 | 949 | * Extracting host and port information from raw address data.
|
935 | 950 | **/
|
| 951 | + |
936 | 952 | + (NSString *)hostFromAddress:(NSData *)address;
|
937 | 953 | + (uint16_t)portFromAddress:(NSData *)address;
|
| 954 | + |
| 955 | ++ (BOOL)isIPv4Address:(NSData *)address; |
| 956 | ++ (BOOL)isIPv6Address:(NSData *)address; |
| 957 | + |
938 | 958 | + (BOOL)getHost:(NSString **)hostPtr port:(uint16_t *)portPtr fromAddress:(NSData *)address;
|
939 | 959 |
|
| 960 | ++ (BOOL)getHost:(NSString **)hostPtr port:(uint16_t *)portPtr family:(sa_family_t *)afPtr fromAddress:(NSData *)address; |
| 961 | + |
940 | 962 | /**
|
941 | 963 | * A few common line separators, for use with the readDataToData:... methods.
|
942 | 964 | **/
|
@@ -1058,7 +1080,22 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
|
1058 | 1080 | * Called when a socket disconnects with or without error.
|
1059 | 1081 | *
|
1060 | 1082 | * If you call the disconnect method, and the socket wasn't already disconnected,
|
1061 |
| - * this delegate method will be called before the disconnect method returns. |
| 1083 | + * then an invocation of this delegate method will be enqueued on the delegateQueue |
| 1084 | + * before the disconnect method returns. |
| 1085 | + * |
| 1086 | + * Note: If the GCDAsyncSocket instance is deallocated while it is still connected, |
| 1087 | + * and the delegate is not also deallocated, then this method will be invoked, |
| 1088 | + * but the sock parameter will be nil. (It must necessarily be nil since it is no longer available.) |
| 1089 | + * This is a generally rare, but is possible if one writes code like this: |
| 1090 | + * |
| 1091 | + * asyncSocket = nil; // I'm implicitly disconnecting the socket |
| 1092 | + * |
| 1093 | + * In this case it may preferrable to nil the delegate beforehand, like this: |
| 1094 | + * |
| 1095 | + * asyncSocket.delegate = nil; // Don't invoke my delegate method |
| 1096 | + * asyncSocket = nil; // I'm implicitly disconnecting the socket |
| 1097 | + * |
| 1098 | + * Of course, this depends on how your state machine is configured. |
1062 | 1099 | **/
|
1063 | 1100 | - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err;
|
1064 | 1101 |
|
|
0 commit comments