︙ | | |
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
-
+
|
*/
typedef bool (^OFSequencedPacketSocketAsyncReceiveBlock)(size_t length,
id _Nullable exception);
/**
* @brief A block which is called when a packet has been sent.
*
* @param data The data which was 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 (^OFSequencedPacketSocketAsyncSendDataBlock)(
OFData *_Nonnull data, id _Nullable exception);
id _Nullable exception);
/**
* @brief A block which is called when the socket accepted a connection.
*
* @param acceptedSocket The socket which has been accepted
* @param exception An exception which occurred while accepting the socket or
* `nil` on success
|
︙ | | |
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
+
+
+
+
+
|
OF_RESERVE_IVARS(OFSequencedPacketSocket, 4)
}
/**
* @brief Whether the socket can block.
*
* By default, a socket can block.
*
* @throw OFSetOptionFailedException The option could not be set
*/
@property (nonatomic) bool canBlock;
/**
* @brief Whether the socket is a listening socket.
*/
@property (readonly, nonatomic, getter=isListening) bool listening;
/**
* @brief The remote address.
*
* @note This only works for accepted sockets!
*
* @throw OFNotOpenException The socket is not open
* @throw OFInvalidArgumentException The socket has no remote address
*/
@property (readonly, nonatomic) const OFSocketAddress *remoteAddress;
/**
* @brief The delegate for asynchronous operations on the socket.
*
* @note The delegate is retained for as long as asynchronous operations are
|
︙ | | |
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
+
+
|
* @brief Receives a packet and stores it into the specified buffer.
*
* If the buffer is too small, the receive operation fails.
*
* @param buffer The buffer to write the packet to
* @param length The length of the buffer
* @return The length of the received packet
* @throw OFReadFailedException Receiving failed
* @throw OFNotOpenException The socket is not open
*/
- (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length;
/**
* @brief Asynchronously receives a packet and stores it into the specified
* buffer.
*
|
︙ | | |
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
+
+
|
#endif
/**
* @brief Sends the specified packet.
*
* @param buffer The buffer to send as a packet
* @param length The length of the buffer
* @throw OFWriteFailedException Sending failed
* @throw OFNotOpenException The socket is not open
*/
- (void)sendBuffer: (const void *)buffer length: (size_t)length;
/**
* @brief Asynchronously sends the specified packet.
*
* @param data The data to send as a packet
|
︙ | | |
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
301
302
303
304
305
306
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
|
+
+
+
+
+
+
+
|
block: (OFSequencedPacketSocketAsyncSendDataBlock)block;
#endif
/**
* @brief Listen on the socket.
*
* @param backlog Maximum length for the queue of pending connections.
* @throw OFListenFailedException Listening failed
* @throw OFNotOpenException The socket is not open
*/
- (void)listenWithBacklog: (int)backlog;
/**
* @brief Listen on the socket.
*
* @throw OFListenFailedException Listening failed
* @throw OFNotOpenException The socket is not open
*/
- (void)listen;
/**
* @brief Accept an incoming connection.
*
* @return An autoreleased sequenced packet socket for the accepted connection.
* @throw OFAcceptFailedException Accepting failed
* @throw OFNotOpenException The socket is not open
*/
- (instancetype)accept;
/**
* @brief Asynchronously accept an incoming connection.
*/
- (void)asyncAccept;
|
︙ | | |
351
352
353
354
355
356
357
358
359
360
361
362
|
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
+
+
|
* @brief Cancels all pending asynchronous requests on the socket.
*/
- (void)cancelAsyncRequests;
/**
* @brief Closes the socket so that it can neither receive nor send any more
* datagrams.
*
* @throw OFNotOpenException The socket is not open
*/
- (void)close;
@end
OF_ASSUME_NONNULL_END
|