ObjFW  Diff

Differences From Artifact [9bff306013]:

To Artifact [7502e6dc2e]:


70
71
72
73
74
75
76
77
78



79
80
81
82

83
84
85
86


87
88
89
90
91
92
93

94
95
96
97
98



99
100
101
102
103
104
105
106
107
108
109
110
111
extern const OFSCTPMessageInfoKey OFSCTPUnordered;
#ifdef __cplusplus
}
#endif

#ifdef OF_HAVE_BLOCKS
/**
 * @brief A block which is called when the socket connected.
 *



 * @param exception An exception which occurred while connecting the socket or
 *		    `nil` on success
 */
typedef void (^OFSCTPSocketAsyncConnectBlock)(id _Nullable exception);


/**
 * @brief A block which is called when a message has been received.
 *


 * @param length The length of the message
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param exception An exception which occurred while receiving or `nil` on
 *		    success
 * @return A bool whether the same block should be used for the next receive
 */
typedef bool (^OFSCTPSocketAsyncReceiveBlock)(size_t length,

    OFSCTPMessageInfo info, id _Nullable exception);

/**
 * @brief A block which is called when a message has been sent.
 *



 * @param exception An exception which occurred while reading or `nil` on
 *		    success
 * @return The data to repeat the send with or nil if it should not repeat
 */
typedef OFData *_Nullable (^OFSCTPSocketAsyncSendDataBlock)(
    id _Nullable exception);
#endif

/**
 * @protocol OFSCTPSocketDelegate OFSCTPSocket.h ObjFW/ObjFW.h
 *
 * A delegate for OFSCTPSocket.
 */







|

>
>
>



|
>


|

>
>




|

|
>
|


|

>
>
>




|
|







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
extern const OFSCTPMessageInfoKey OFSCTPUnordered;
#ifdef __cplusplus
}
#endif

#ifdef OF_HAVE_BLOCKS
/**
 * @brief A handler which is called when the socket connected.
 *
 * @param socket The socket which connected
 * @param host The host connected to
 * @param port The port on the host connected to
 * @param exception An exception which occurred while connecting the socket or
 *		    `nil` on success
 */
typedef void (^OFSCTPSocketConnectedHandler)(OFSCTPSocket *socket,
    OFString *host, uint16_t port, id _Nullable exception);

/**
 * @brief A handler which is called when a message has been received.
 *
 * @param socket The SCTP socket which received a message
 * @param buffer The buffer the message has been written to
 * @param length The length of the message
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param exception An exception which occurred while receiving or `nil` on
 *		    success
 * @return A bool whether the same handler should be used for the next receive
 */
typedef bool (^OFSCTPSocketMessageReceivedHandler)(OFSCTPSocket *socket,
    void *buffer, size_t length, OFSCTPMessageInfo _Nullable info,
    id _Nullable exception);

/**
 * @brief A handler which is called when a message has been sent.
 *
 * @param socket The SCTP socket which sent a message
 * @param data The data which was sent
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param exception An exception which occurred while reading or `nil` on
 *		    success
 * @return The data to repeat the send with or nil if it should not repeat
 */
typedef OFData *_Nullable (^OFSCTPSocketDataSentHandler)(OFSCTPSocket *socket,
    OFData *data, OFSCTPMessageInfo _Nullable info, id _Nullable exception);
#endif

/**
 * @protocol OFSCTPSocketDelegate OFSCTPSocket.h ObjFW/ObjFW.h
 *
 * A delegate for OFSCTPSocket.
 */
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
 *
 * @param socket The SCTP socket which received a message
 * @param buffer The buffer the message has been written to
 * @param length The length of the message
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param exception An exception that occurred while receiving, or nil on
 *		    success
 * @return A bool whether the same block should be used for the next receive
 */
-	  (bool)socket: (OFSCTPSocket *)socket
  didReceiveIntoBuffer: (void *)buffer
		length: (size_t)length
		  info: (nullable OFSCTPMessageInfo)info
	     exception: (nullable id)exception;








|







140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
 *
 * @param socket The SCTP socket which received a message
 * @param buffer The buffer the message has been written to
 * @param length The length of the message
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param exception An exception that occurred while receiving, or nil on
 *		    success
 * @return A bool whether the same handler should be used for the next receive
 */
-	  (bool)socket: (OFSCTPSocket *)socket
  didReceiveIntoBuffer: (void *)buffer
		length: (size_t)length
		  info: (nullable OFSCTPMessageInfo)info
	     exception: (nullable id)exception;

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

#ifdef OF_HAVE_BLOCKS
/**
 * @brief Asynchronously connect the OFSCTPSocket to the specified destination.
 *
 * @param host The host to connect to
 * @param port The port on the host to connect to
 * @param block The block to execute once the connection has been established

 */
- (void)asyncConnectToHost: (OFString *)host
		      port: (uint16_t)port
		     block: (OFSCTPSocketAsyncConnectBlock)block;

/**
 * @brief Asynchronously connect the OFSCTPSocket to the specified destination.
 *
 * @param host The host to connect to
 * @param port The port on the host to connect to
 * @param runLoopMode The run loop mode in which to perform the async connect
 * @param block The block to execute once the connection has been established

 */
- (void)asyncConnectToHost: (OFString *)host
		      port: (uint16_t)port
	       runLoopMode: (OFRunLoopMode)runLoopMode
		     block: (OFSCTPSocketAsyncConnectBlock)block;
#endif

/**
 * @brief Bind 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.







|
>



|







|
>




|







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

#ifdef OF_HAVE_BLOCKS
/**
 * @brief Asynchronously connect the OFSCTPSocket to the specified destination.
 *
 * @param host The host to connect to
 * @param port The port on the host to connect to
 * @param handler The handler to execute once the connection has been
 *		  established
 */
- (void)asyncConnectToHost: (OFString *)host
		      port: (uint16_t)port
		   handler: (OFSCTPSocketConnectedHandler)handler;

/**
 * @brief Asynchronously connect the OFSCTPSocket to the specified destination.
 *
 * @param host The host to connect to
 * @param port The port on the host to connect to
 * @param runLoopMode The run loop mode in which to perform the async connect
 * @param handler The handler to execute once the connection has been
 *		  established
 */
- (void)asyncConnectToHost: (OFString *)host
		      port: (uint16_t)port
	       runLoopMode: (OFRunLoopMode)runLoopMode
		   handler: (OFSCTPSocketConnectedHandler)handler;
#endif

/**
 * @brief Bind 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.
307
308
309
310
311
312
313
314
315
316
317
318

319

320
321
322
323
324
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
 * @brief Asynchronously receives a message and stores it into the specified
 *	  buffer.
 *
 * If the buffer is too small, the message is truncated.
 *
 * @param buffer The buffer to write the message to
 * @param length The length of the buffer
 * @param block The block to call when the message has been received. If the
 *		block returns true, it will be called again with the same
 *		buffer and maximum length when more messages have been received.
 *		If you want the next method in the queue to handle the message
 *		received next, you need to return false from the method.

 */

- (void)asyncReceiveWithInfoIntoBuffer: (void *)buffer
				length: (size_t)length
				 block: (OFSCTPSocketAsyncReceiveBlock)block;

/**
 * @brief Asynchronously receives a message and stores it into the specified
 *	  buffer.
 *
 * If the buffer is too small, the message is truncated.
 *
 * @param buffer The buffer to write the message to
 * @param length The length of the buffer
 * @param runLoopMode The run loop mode in which to perform the asynchronous
 *		      receive
 * @param block The block to call when the message has been received. If the
 *		block returns true, it will be called again with the same
 *		buffer and maximum length when more messages have been received.
 *		If you want the next method in the queue to handle the message
 *		received next, you need to return false from the method.

 */

- (void)asyncReceiveWithInfoIntoBuffer: (void *)buffer
				length: (size_t)length
			   runLoopMode: (OFRunLoopMode)runLoopMode
				 block: (OFSCTPSocketAsyncReceiveBlock)block;
#endif

/**
 * @brief Sends the specified message on the specified stream.
 *
 * @param buffer The buffer to send as a message
 * @param length The length of the buffer







|
|
|
|
|
>

>
|
|
|











|
|
|
|
|
>

>
|
|
|
|







319
320
321
322
323
324
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
 * @brief Asynchronously receives a message and stores it into the specified
 *	  buffer.
 *
 * If the buffer is too small, the message is truncated.
 *
 * @param buffer The buffer to write the message to
 * @param length The length of the buffer
 * @param handler The handler to call when the message has been received. If the
 *		  handler returns true, it will be called again with the same
 *		  buffer and maximum length when more messages have been
 *		  received. If you want the next method in the queue to handle
 *		  the message received next, you need to return false from the
 *		  method.
 */
- (void)
    asyncReceiveWithInfoIntoBuffer: (void *)buffer
			    length: (size_t)length
			   handler: (OFSCTPSocketMessageReceivedHandler)handler;

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

/**
 * @brief Sends the specified message on the specified stream.
 *
 * @param buffer The buffer to send as a message
 * @param length The length of the buffer
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
405
406
407
408
409
410
411

#ifdef OF_HAVE_BLOCKS
/**
 * @brief Asynchronously sends the specified message on the specified stream.
 *
 * @param data The data to send as a message
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param block The block to call when the message has been sent. It should
 *		return the data for the next send with the same callback or nil
 *		if it should not repeat.
 */
- (void)asyncSendData: (OFData *)data
		 info: (nullable OFSCTPMessageInfo)info
		block: (OFSCTPSocketAsyncSendDataBlock)block;

/**
 * @brief Asynchronously sends the specified message on the specified stream.
 *
 * @param data The data to send as a message
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param runLoopMode The run loop mode in which to perform the asynchronous
 *		      send
 * @param block The block to call when the message has been sent. It should
 *		return the data for the next send with the same callback or nil
 *		if it should not repeat.
 */
- (void)asyncSendData: (OFData *)data
		 info: (nullable OFSCTPMessageInfo)info
	  runLoopMode: (OFRunLoopMode)runLoopMode
		block: (OFSCTPSocketAsyncSendDataBlock)block;
#endif
@end

OF_ASSUME_NONNULL_END







|
|
|



|








|
|
|




|




394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427

#ifdef OF_HAVE_BLOCKS
/**
 * @brief Asynchronously sends the specified message on the specified stream.
 *
 * @param data The data to send as a message
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param handler The handler to call when the message has been sent. It should
 *		  return the data for the next send with the same callback or
 *		  nil if it should not repeat.
 */
- (void)asyncSendData: (OFData *)data
		 info: (nullable OFSCTPMessageInfo)info
	      handler: (OFSCTPSocketDataSentHandler)handler;

/**
 * @brief Asynchronously sends the specified message on the specified stream.
 *
 * @param data The data to send as a message
 * @param info Information about the message, see @ref OFSCTPMessageInfo
 * @param runLoopMode The run loop mode in which to perform the asynchronous
 *		      send
 * @param handler The handler to call when the message has been sent. It should
 *		  return the data for the next send with the same callback or
 *		  nil if it should not repeat.
 */
- (void)asyncSendData: (OFData *)data
		 info: (nullable OFSCTPMessageInfo)info
	  runLoopMode: (OFRunLoopMode)runLoopMode
	      handler: (OFSCTPSocketDataSentHandler)handler;
#endif
@end

OF_ASSUME_NONNULL_END