ObjFW  Diff

Differences From Artifact [b1604a829a]:

To Artifact [362b51f3c0]:


81
82
83
84
85
86
87
88
89


90
91
92
93
94
95
96
81
82
83
84
85
86
87


88
89
90
91
92
93
94
95
96







-
-
+
+







/*!
 * @class OFUDPSocket OFUDPSocket.h ObjFW/OFUDPSocket.h
 *
 * @brief A class which provides methods to create and use UDP sockets.
 *
 * Addresses are of type @ref of_socket_address_t. You can use
 * @ref resolveAddressForHost:port:address: to create an address for a host /
 * port pair and @ref getHost:andPort:forAddress: to get the host / port pair
 * for an address. If you want to compare two addresses, you can use
 * port pair and @ref of_socket_address_ip_string to get the IP string / port
 * pair for an address. If you want to compare two addresses, you can use
 * @ref of_socket_address_equal and you can use @ref of_socket_address_hash to
 * get a hash to use in e.g. @ref OFMapTable.
 *
 * @warning Even though the OFCopying protocol is implemented, it does *not*
 *	    return an independent copy of the socket, but instead retains it.
 *	    This is so that the socket can be used as a key for a dictionary,
 *	    so context can be associated with a socket. Using a socket in more
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
157
158
159
160
161
162
163













164
165
166
167
168
169
170







-
-
-
-
-
-
-
-
-
-
-
-
-







 */
+ (void)asyncResolveAddressForHost: (OFString *)host
			      port: (uint16_t)port
			     block: (of_udp_socket_async_resolve_block_t)block;
# endif
#endif

/*!
 * @brief Gets the host and port for the specified address.
 *
 * @param host A pointer to an @ref OFString *. If it is not NULL, it will be
 *	       set to the host of the host / port pair.
 * @param port A pointer to an uint16_t. If it is not NULL, the port of the
 *	       host / port pair will be written to it.
 * @param address The address for which the host and port should be retrieved
 */
+ (void)getHost: (OFString *__autoreleasing _Nonnull *_Nullable)host
	andPort: (nullable uint16_t *)port
     forAddress: (of_socket_address_t *)address;

/*!
 * @brief Binds the socket to the specified host and port.
 *
 * @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for
 *	       IPv6 to bind to all.
 * @param port The port to bind to. If the port is 0, an unused port will be
 *	       chosen, which can be obtained using the return value.