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
184
185
186
187
|
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
184
185
186
187
|
-
+
-
+
-
+
-
+
|
@public
# ifdef OF_HAVE_BLOCKS
of_tcp_socket_async_accept_block_t _block;
# endif
}
@end
@interface OFRunLoopUDPReceiveQueueItem: OFRunLoopQueueItem
@interface OFRunLoopDatagramReceiveQueueItem: OFRunLoopQueueItem
{
@public
# ifdef OF_HAVE_BLOCKS
of_udp_socket_async_receive_block_t _block;
of_datagram_socket_async_receive_block_t _block;
# endif
void *_buffer;
size_t _length;
}
@end
@interface OFRunLoopUDPSendQueueItem: OFRunLoopQueueItem
@interface OFRunLoopDatagramSendQueueItem: OFRunLoopQueueItem
{
@public
# ifdef OF_HAVE_BLOCKS
of_udp_socket_async_send_data_block_t _block;
of_datagram_socket_async_send_data_block_t _block;
# endif
OFData *_data;
of_socket_address_t _receiver;
}
@end
#endif
|
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
|
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
|
-
+
|
[_block release];
[super dealloc];
}
# endif
@end
@implementation OFRunLoopUDPReceiveQueueItem
@implementation OFRunLoopDatagramReceiveQueueItem
- (bool)handleObject: (id)object
{
size_t length;
of_socket_address_t address;
id exception = nil;
@try {
|
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
|
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
|
-
+
|
[_block release];
[super dealloc];
}
# endif
@end
@implementation OFRunLoopUDPSendQueueItem
@implementation OFRunLoopDatagramSendQueueItem
- (bool)handleObject: (id)object
{
id exception = nil;
OFData *newData, *oldData;
@try {
[object sendBuffer: _data.items
|
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
|
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
|
-
-
-
-
+
+
+
+
-
+
-
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
+
-
+
|
# ifdef OF_HAVE_BLOCKS
queueItem->_block = [block copy];
# endif
QUEUE_ITEM
}
+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)sock
buffer: (void *)buffer
length: (size_t)length
mode: (of_run_loop_mode_t)mode
+ (void)of_addAsyncReceiveForDatagramSocket: (OFDatagramSocket *)sock
buffer: (void *)buffer
length: (size_t)length
mode: (of_run_loop_mode_t)mode
# ifdef OF_HAVE_BLOCKS
block: (of_udp_socket_async_receive_block_t)
block: (of_datagram_socket_async_receive_block_t)block
block
# endif
delegate: (id <OFUDPSocketDelegate>)delegate
delegate: (id <OFDatagramSocketDelegate>)delegate
{
NEW_READ(OFRunLoopUDPReceiveQueueItem, sock, mode)
NEW_READ(OFRunLoopDatagramReceiveQueueItem, sock, mode)
queueItem->_delegate = [delegate retain];
# ifdef OF_HAVE_BLOCKS
queueItem->_block = [block copy];
# endif
queueItem->_buffer = buffer;
queueItem->_length = length;
QUEUE_ITEM
}
+ (void)of_addAsyncSendForUDPSocket: (OFUDPSocket *)sock
data: (OFData *)data
receiver: (const of_socket_address_t *)receiver
mode: (of_run_loop_mode_t)mode
+ (void)of_addAsyncSendForDatagramSocket: (OFDatagramSocket *)sock
data: (OFData *)data
receiver: (const of_socket_address_t *)receiver
mode: (of_run_loop_mode_t)mode
# ifdef OF_HAVE_BLOCKS
block: (of_udp_socket_async_send_data_block_t)
block: (of_datagram_socket_async_send_data_block_t)block
block
# endif
delegate: (id <OFUDPSocketDelegate>)delegate
delegate: (id <OFDatagramSocketDelegate>)delegate
{
NEW_WRITE(OFRunLoopUDPSendQueueItem, sock, mode)
NEW_WRITE(OFRunLoopDatagramSendQueueItem, sock, mode)
queueItem->_delegate = [delegate retain];
# ifdef OF_HAVE_BLOCKS
queueItem->_block = [block copy];
# endif
queueItem->_data = [data copy];
queueItem->_receiver = *receiver;
|