︙ | | |
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
-
-
|
*/
typedef bool (^OFDatagramSocketAsyncReceiveBlock)(size_t length,
const OFSocketAddress *_Nonnull sender, id _Nullable exception);
/**
* @brief A block which is called when a packet has been sent.
*
* @param data The data which was sent
* @param receiver The receiver for the packet
* @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 (^OFDatagramSocketAsyncSendDataBlock)(
OFData *_Nonnull data, const OFSocketAddress *_Nonnull receiver,
id _Nullable exception);
#endif
/**
* @protocol OFDatagramSocketDelegate OFDatagramSocket.h \
* ObjFW/OFDatagramSocket.h
*
|
︙ | | |
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
+
+
+
+
|
OF_RESERVE_IVARS(OFDatagramSocket, 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 can send to broadcast addresses.
*
* @throw OFSetOptionFailedException The option could not be set
*/
@property (nonatomic) bool canSendToBroadcastAddresses;
/**
* @brief The delegate for asynchronous operations on the socket.
*
* @note The delegate is retained for as long as asynchronous operations are
|
︙ | | |
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
+
+
|
* 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 sender A pointer to an @ref OFSocketAddress, which will be set to the
* address of the sender
* @return The length of the received datagram
* @throw OFReadFailedException Receiving failed
* @throw OFNotOpenException The socket is not open
*/
- (size_t)receiveIntoBuffer: (void *)buffer
length: (size_t)length
sender: (OFSocketAddress *)sender;
/**
* @brief Asynchronously receives a datagram and stores it into the specified
|
︙ | | |
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
+
+
|
/**
* @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
* @param receiver A pointer to an @ref OFSocketAddress to which the datagram
* should be sent
* @throw OFWriteFailedException Sending failed
* @throw OFNotOpenException The socket is not open
*/
- (void)sendBuffer: (const void *)buffer
length: (size_t)length
receiver: (const OFSocketAddress *)receiver;
/**
* @brief Asynchronously sends the specified datagram to the specified address.
|
︙ | | |
296
297
298
299
300
301
302
303
304
305
306
307
|
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
+
+
|
* @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
|