ObjFW  Diff

Differences From Artifact [ad5fd6fb30]:

To Artifact [29dec683be]:


13
14
15
16
17
18
19

20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"
#import "OFKernelEventObserver.h"


#import "socket.h"

OF_ASSUME_NONNULL_BEGIN

/*! @file */








>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"
#import "OFKernelEventObserver.h"
#import "OFRunLoop.h"

#import "socket.h"

OF_ASSUME_NONNULL_BEGIN

/*! @file */

217
218
219
220
221
222
223



























224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242





















243
244
245
246
247
248
249
 */
- (void)asyncReceiveIntoBuffer: (void *)buffer
			length: (size_t)length
			target: (id)target
		      selector: (SEL)selector
		       context: (nullable id)context;




























#ifdef OF_HAVE_BLOCKS
/*!
 * @brief Asynchronously receives a datagram and stores it into the specified
 *	  buffer.
 *
 * If the buffer is too small, the datagram is truncated.
 *
 * @param buffer The buffer to write the datagram to
 * @param length The length of the buffer
 * @param block The block to call when the datagram has been received. If the
 *		block returns true, it will be called again with the same
 *		buffer and maximum length when more datagrams have been
 *		received. If you want the next method in the queue to handle
 *		the datagram received next, you need to return false from the
 *		method.
 */
- (void)asyncReceiveIntoBuffer: (void *)buffer
			length: (size_t)length
			 block: (of_udp_socket_async_receive_block_t)block;





















#endif

/*!
 * @brief Sends the specified datagram to the specified address.
 *
 * @param buffer The buffer to send as a datagram
 * @param length The length of the buffer







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
 */
- (void)asyncReceiveIntoBuffer: (void *)buffer
			length: (size_t)length
			target: (id)target
		      selector: (SEL)selector
		       context: (nullable id)context;

/*!
 * @brief Asynchronously receives a datagram and stores it into the specified
 *	  buffer.
 *
 * If the buffer is too small, the datagram is truncated.
 *
 * @param buffer The buffer to write the datagram to
 * @param length The length of the buffer
 * @param runLoopMode The run loop mode in which to perform the async receive
 * @param target The target on which the selector should be called when the
 *		 datagram has been received. If the method returns true, it
 *		 will be called again with the same buffer and maximum length
 *		 when more datagrams have been received. If you want the next
 *		 method in the queue to handle the datagram received next, you
 *		 need to return false from the method.
 * @param selector The selector to call on the target. The signature must be
 *		   `bool (OFUDPSocket *socket, void *buffer, size_t length,
 *		   of_socket_address_t sender, id context, id exception)`.
 * @param context A context object to pass along to the target
 */
- (void)asyncReceiveIntoBuffer: (void *)buffer
			length: (size_t)length
		   runLoopMode: (of_run_loop_mode_t)runLoopMode
			target: (id)target
		      selector: (SEL)selector
		       context: (nullable id)context;

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief Asynchronously receives a datagram and stores it into the specified
 *	  buffer.
 *
 * If the buffer is too small, the datagram is truncated.
 *
 * @param buffer The buffer to write the datagram to
 * @param length The length of the buffer
 * @param block The block to call when the datagram has been received. If the
 *		block returns true, it will be called again with the same
 *		buffer and maximum length when more datagrams have been
 *		received. If you want the next method in the queue to handle
 *		the datagram received next, you need to return false from the
 *		method.
 */
- (void)asyncReceiveIntoBuffer: (void *)buffer
			length: (size_t)length
			 block: (of_udp_socket_async_receive_block_t)block;

/*!
 * @brief Asynchronously receives a datagram and stores it into the specified
 *	  buffer.
 *
 * If the buffer is too small, the datagram is truncated.
 *
 * @param buffer The buffer to write the datagram to
 * @param length The length of the buffer
 * @param runLoopMode The run loop mode in which to perform the async receive
 * @param block The block to call when the datagram has been received. If the
 *		block returns true, it will be called again with the same
 *		buffer and maximum length when more datagrams have been
 *		received. If you want the next method in the queue to handle
 *		the datagram received next, you need to return false from the
 *		method.
 */
- (void)asyncReceiveIntoBuffer: (void *)buffer
			length: (size_t)length
		   runLoopMode: (of_run_loop_mode_t)runLoopMode
			 block: (of_udp_socket_async_receive_block_t)block;
#endif

/*!
 * @brief Sends the specified datagram to the specified address.
 *
 * @param buffer The buffer to send as a datagram
 * @param length The length of the buffer
276
277
278
279
280
281
282




























283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300




















301
302
303
304
305
306
307
- (void)asyncSendBuffer: (const void *)buffer
		 length: (size_t)length
	       receiver: (of_socket_address_t)receiver
		 target: (id)target
	       selector: (SEL)selector
		context: (nullable id)context;





























#ifdef OF_HAVE_BLOCKS
/*!
 * @brief Asynchronously sends the specified datagram to the specified address.
 *
 * @param buffer The buffer to send as a datagram
 * @param length The length of the buffer
 * @param receiver A pointer to an @ref of_socket_address_t to which the
 *		   datagram should be sent
 * @param block The block to call when the packet has been sent. It should
 *		return the length for the next send with the same callback or 0
 *		if it should not repeat. The buffer and receiver may be
 *		changed, so that every time a new buffer, length and receiver
 *		can be specified while the callback stays the same.
 */
- (void)asyncSendBuffer: (const void *)buffer
		 length: (size_t)length
	       receiver: (of_socket_address_t)receiver
		  block: (of_udp_socket_async_send_block_t)block;




















#endif

/*!
 * @brief Cancels all pending asynchronous requests on the socket.
 */
- (void)cancelAsyncRequests;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
- (void)asyncSendBuffer: (const void *)buffer
		 length: (size_t)length
	       receiver: (of_socket_address_t)receiver
		 target: (id)target
	       selector: (SEL)selector
		context: (nullable id)context;

/*!
 * @brief Asynchronously sends the specified datagram to the specified address.
 *
 * @param buffer The buffer to send as a datagram
 * @param length The length of the buffer
 * @param receiver A pointer to an @ref of_socket_address_t to which the
 *		   datagram should be sent
 * @param runLoopMode The run loop mode in which to perform the async send
 * @param target The target on which the selector should be called when the
 *		 packet has been sent. The method should return the length for
 *		 the next send with the same callback or 0 if it should not
 *		 repeat. The buffer and receiver may be changed, so that every
 *		 time a new buffer, length and receiver can be specified while
 *		 the callback stays the same.
 * @param selector The selector to call on the target. The signature must be
 *		   `size_t (OFUDPSocket *socket, const void **buffer,
 *		   size_t bytesSent, of_socket_address_t *receiver, id context,
 *		   id exception)`.
 * @param context A context object to pass along to the target
 */
- (void)asyncSendBuffer: (const void *)buffer
		 length: (size_t)length
	       receiver: (of_socket_address_t)receiver
	    runLoopMode: (of_run_loop_mode_t)runLoopMode
		 target: (id)target
	       selector: (SEL)selector
		context: (nullable id)context;

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief Asynchronously sends the specified datagram to the specified address.
 *
 * @param buffer The buffer to send as a datagram
 * @param length The length of the buffer
 * @param receiver A pointer to an @ref of_socket_address_t to which the
 *		   datagram should be sent
 * @param block The block to call when the packet has been sent. It should
 *		return the length for the next send with the same callback or 0
 *		if it should not repeat. The buffer and receiver may be
 *		changed, so that every time a new buffer, length and receiver
 *		can be specified while the callback stays the same.
 */
- (void)asyncSendBuffer: (const void *)buffer
		 length: (size_t)length
	       receiver: (of_socket_address_t)receiver
		  block: (of_udp_socket_async_send_block_t)block;

/*!
 * @brief Asynchronously sends the specified datagram to the specified address.
 *
 * @param buffer The buffer to send as a datagram
 * @param length The length of the buffer
 * @param receiver A pointer to an @ref of_socket_address_t to which the
 *		   datagram should be sent
 * @param runLoopMode The run loop mode in which to perform the async send
 * @param block The block to call when the packet has been sent. It should
 *		return the length for the next send with the same callback or 0
 *		if it should not repeat. The buffer and receiver may be
 *		changed, so that every time a new buffer, length and receiver
 *		can be specified while the callback stays the same.
 */
- (void)asyncSendBuffer: (const void *)buffer
		 length: (size_t)length
	       receiver: (of_socket_address_t)receiver
	    runLoopMode: (of_run_loop_mode_t)runLoopMode
		  block: (of_udp_socket_async_send_block_t)block;
#endif

/*!
 * @brief Cancels all pending asynchronous requests on the socket.
 */
- (void)cancelAsyncRequests;