Index: src/OFDNSResolver.h ================================================================== --- src/OFDNSResolver.h +++ src/OFDNSResolver.h @@ -20,10 +20,12 @@ #import "OFRunLoop.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN +#define OF_DNS_RESOLVER_BUFFER_LENGTH 512 + @class OFArray OF_GENERIC(ObjectType); @class OFDNSResolverQuery; @class OFDate; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @@ -85,10 +87,11 @@ OFDate *_lastConfigReload; OFUDPSocket *_IPv4Socket; #ifdef OF_HAVE_IPV6 OFUDPSocket *_IPv6Socket; #endif + char _buffer[OF_DNS_RESOLVER_BUFFER_LENGTH]; OFMutableDictionary OF_GENERIC(OFNumber *, OFDNSResolverQuery *) *_queries; } /*! Index: src/OFDNSResolver.m ================================================================== --- src/OFDNSResolver.m +++ src/OFDNSResolver.m @@ -69,10 +69,12 @@ #ifndef SOCK_DNS # define SOCK_DNS 0 #endif +#define BUFFER_LENGTH OF_DNS_RESOLVER_BUFFER_LENGTH + /* * RFC 1035 doesn't specify if pointers to pointers are allowed, and if so how * many. Since it's unspecified, we have to assume that it might happen, but we * also want to limit it to avoid DoS. Limiting it to 16 levels of pointers and * immediately rejecting pointers to itself seems like a fair balance. @@ -226,11 +228,11 @@ socketAddresses: (OFData *)socketAddresses context: (id)context exception: (id)exception; @end -@interface OFDNSResolver () +@interface OFDNSResolver () - (void)of_setDefaults; - (void)of_obtainSystemConfig; #if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_3DS) - (void)of_parseHosts: (OFString *)path; # if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4) @@ -259,22 +261,10 @@ selector: (SEL)selector context: (id)context; - (void)of_sendQuery: (OFDNSResolverQuery *)query runLoopMode: (of_run_loop_mode_t)runLoopMode; - (void)of_queryWithIDTimedOut: (OFDNSResolverQuery *)query; -- (size_t)of_socket: (OFUDPSocket *)sock - didSendBuffer: (void **)buffer - bytesSent: (size_t)bytesSent - receiver: (of_socket_address_t *)receiver - context: (OFDNSResolverQuery *)query - exception: (id)exception; -- (bool)of_socket: (OFUDPSocket *)sock - didReceiveIntoBuffer: (unsigned char *)buffer - length: (size_t)length - sender: (of_socket_address_t)sender - context: (id)context - exception: (id)exception; @end #ifndef OF_WII static OFString * domainFromHostname(void) @@ -1289,12 +1279,14 @@ [_staticHosts release]; [_nameServers release]; [_localDomain release]; [_searchDomains release]; [_lastConfigReload release]; + [_IPv4Socket cancelAsyncRequests]; [_IPv4Socket release]; #ifdef OF_HAVE_IPV6 + [_IPv6Socket cancelAsyncRequests]; [_IPv6Socket release]; #endif [_queries release]; [super dealloc]; @@ -1790,10 +1782,13 @@ _IPv6Socket = [[OFUDPSocket alloc] init]; [_IPv6Socket of_bindToAddress: &address extraType: SOCK_DNS]; [_IPv6Socket setBlocking: false]; + [_IPv6Socket setDelegate: self]; + [_IPv6Socket asyncReceiveIntoBuffer: _buffer + length: BUFFER_LENGTH]; } sock = _IPv6Socket; break; #endif @@ -1804,10 +1799,13 @@ _IPv4Socket = [[OFUDPSocket alloc] init]; [_IPv4Socket of_bindToAddress: &address extraType: SOCK_DNS]; [_IPv4Socket setBlocking: false]; + [_IPv4Socket setDelegate: self]; + [_IPv4Socket asyncReceiveIntoBuffer: _buffer + length: BUFFER_LENGTH]; } sock = _IPv4Socket; break; default: @@ -1815,15 +1813,11 @@ } [sock asyncSendBuffer: [query->_queryData items] length: [query->_queryData count] receiver: query->_usedNameServer - runLoopMode: runLoopMode - target: self - selector: @selector(of_socket:didSendBuffer:bytesSent: - receiver:context:exception:) - context: query]; + runLoopMode: runLoopMode]; } - (void)of_queryWithIDTimedOut: (OFDNSResolverQuery *)query { OFResolveHostFailedException *exception; @@ -1848,10 +1842,23 @@ } query = [[query retain] autorelease]; [_queries removeObjectForKey: query->_ID]; + /* + * Cancel any pending requests, to avoid a send being still pending and + * trying to access the query once it no longer exists. + */ + [_IPv4Socket cancelAsyncRequests]; + [_IPv4Socket asyncReceiveIntoBuffer: _buffer + length: BUFFER_LENGTH]; +#ifdef OF_HAVE_IPV6 + [_IPv6Socket cancelAsyncRequests]; + [_IPv6Socket asyncReceiveIntoBuffer: _buffer + length: BUFFER_LENGTH]; +#endif + exception = [OFResolveHostFailedException exceptionWithHost: query->_host recordClass: query->_recordClass recordType: query->_recordType error: OF_DNS_RESOLVER_ERROR_TIMEOUT]; @@ -1858,62 +1865,21 @@ callback(query->_target, query->_selector, self, query->_domainName, nil, nil, nil, query->_context, exception); } -- (size_t)of_socket: (OFUDPSocket *)sock - didSendBuffer: (void **)buffer - bytesSent: (size_t)bytesSent - receiver: (of_socket_address_t *)receiver - context: (OFDNSResolverQuery *)query - exception: (id)exception -{ - if (exception != nil) { - query = [[query retain] autorelease]; - [_queries removeObjectForKey: query->_ID]; - - callback(query->_target, query->_selector, self, - query->_domainName, nil, nil, nil, query->_context, - exception); - - return 0; - } - - /* - * Pass the query as context to make sure that its buffer stays around - * for as long as our receive is pending. - */ - [sock asyncReceiveIntoBuffer: [query allocMemoryWithSize: 512] - length: 512 - runLoopMode: [[OFRunLoop currentRunLoop] currentMode] - target: self - selector: @selector(of_socket:didReceiveIntoBuffer: - length:sender:context:exception:) - context: query]; - - return 0; -} - -- (bool)of_socket: (OFUDPSocket *)sock - didReceiveIntoBuffer: (unsigned char *)buffer +- (bool)socket: (OF_KINDOF(OFUDPSocket *))sock + didReceiveIntoBuffer: (void *)buffer_ length: (size_t)length sender: (of_socket_address_t)sender - context: (id)context - exception: (id)exception { + unsigned char *buffer = buffer_; OFDictionary *answerRecords = nil, *authorityRecords = nil; OFDictionary *additionalRecords = nil; OFNumber *ID; OFDNSResolverQuery *query; - if (exception != nil) { - if ([exception respondsToSelector: @selector(errNo)]) - return ([exception errNo] == EINTR); - - return false; - } - if (length < 2) /* We can't get the ID to get the query. Ignore packet. */ return true; ID = [OFNumber numberWithUInt16: (buffer[0] << 8) | buffer[1]]; @@ -1985,11 +1951,11 @@ runLoopMode: runLoopMode target: query->_target selector: query->_selector context: query->_context]; - return false; + return true; } error = OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR; break; case 4: @@ -2034,18 +2000,18 @@ additionalRecords = parseSection(buffer, length, &i, numAdditionalRecords); } @catch (id e) { callback(query->_target, query->_selector, self, query->_domainName, nil, nil, nil, query->_context, e); - return false; + return true; } callback(query->_target, query->_selector, self, query->_domainName, answerRecords, authorityRecords, additionalRecords, query->_context, nil); - return false; + return true; } - (void)asyncResolveSocketAddressesForHost: (OFString *)host target: (id)target selector: (SEL)selector Index: src/OFRunLoop+Private.h ================================================================== --- src/OFRunLoop+Private.h +++ src/OFRunLoop+Private.h @@ -23,10 +23,15 @@ #endif OF_ASSUME_NONNULL_BEGIN @class OFRunLoop_State; + +@protocol OFTCPSocketDelegate_Private +- (void)of_socketDidConnect: (OF_KINDOF(OFTCPSocket *))socket + exception: (nullable id)exception; +@end @interface OFRunLoop () + (void)of_setMainRunLoop: (OFRunLoop *)runLoop; #ifdef OF_HAVE_SOCKETS + (void)of_addAsyncReadForStream: (OFStream *) @@ -52,30 +57,26 @@ length: (size_t)length mode: (of_run_loop_mode_t)mode delegate: (id )delegate; + (void)of_addAsyncConnectForTCPSocket: (OFTCPSocket *)socket mode: (of_run_loop_mode_t)mode - target: (id)target - selector: (SEL)selector; + delegate: (id ) + delegate; + (void)of_addAsyncAcceptForTCPSocket: (OFTCPSocket *)socket mode: (of_run_loop_mode_t)mode delegate: (id )delegate; + (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)socket buffer: (void *)buffer length: (size_t)length mode: (of_run_loop_mode_t)mode - target: (id)target - selector: (SEL)selector - context: (nullable id)context; + delegate: (id )delegate; + (void)of_addAsyncSendForUDPSocket: (OFUDPSocket *)socket buffer: (const void *)buffer length: (size_t)length receiver: (of_socket_address_t)receiver mode: (of_run_loop_mode_t)mode - target: (id)target - selector: (SEL)selector - context: (nullable id)context; + delegate: (id )delegate; # ifdef OF_HAVE_BLOCKS + (void)of_addAsyncReadForStream: (OFStream *) stream buffer: (void *)buffer length: (size_t)length Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -73,14 +73,10 @@ #ifdef OF_HAVE_SOCKETS @interface OFRunLoop_QueueItem: OFObject { @public id _delegate; - /* TODO: Remove once everything is moved to using delegates */ - id _target; - SEL _selector; - id _context; } - (bool)handleObject: (id)object; @end @@ -301,12 +297,10 @@ } - (void)dealloc { [_delegate release]; - [_target release]; - [_context release]; [super dealloc]; } @end @@ -545,22 +539,22 @@ @implementation OFRunLoop_ConnectQueueItem - (bool)handleObject: (id)object { id exception = nil; int errNo; - void (*func)(id, SEL, OFTCPSocket *, id, id); if ((errNo = [object of_socketError]) != 0) exception = [OFConnectionFailedException exceptionWithHost: nil port: 0 socket: object errNo: errNo]; - func = (void (*)(id, SEL, OFTCPSocket *, id, id)) - [_target methodForSelector: _selector]; - func(_target, _selector, object, _context, exception); + if ([_delegate respondsToSelector: + @selector(of_socketDidConnect:exception:)]) + [_delegate of_socketDidConnect: object + exception: exception]; return false; } @end @@ -631,18 +625,27 @@ # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, address, exception); else { # endif - bool (*func)(id, SEL, OFUDPSocket *, void *, size_t, - of_socket_address_t, id, id) = - (bool (*)(id, SEL, OFUDPSocket *, void *, size_t, - of_socket_address_t, id, id)) - [_target methodForSelector: _selector]; - - return func(_target, _selector, object, _buffer, length, - address, _context, exception); + if (exception == nil) { + if (![_delegate respondsToSelector: @selector(socket: + didReceiveIntoBuffer:length:sender:)]) + return false; + + return [_delegate socket: object + didReceiveIntoBuffer: _buffer + length: length + sender: address]; + } else { + if ([_delegate respondsToSelector: + @selector(socket:didFailToReceiveWithException:)]) + [_delegate socket: object + didFailToReceiveWithException: exception]; + + return false; + } # ifdef OF_HAVE_BLOCKS } # endif } @@ -675,21 +678,29 @@ (exception == nil ? _length : 0), &_receiver, exception); return (_length > 0); } else { # endif - size_t (*func)(id, SEL, OFUDPSocket *, const void *, size_t, - of_socket_address_t *, id, id) = - (size_t (*)(id, SEL, OFUDPSocket *, const void *, size_t, - of_socket_address_t *, id, id)) - [_target methodForSelector: _selector]; - - _length = func(_target, _selector, object, &_buffer, - (exception == nil ? _length : 0), &_receiver, _context, - exception); - - return (_length > 0); + if (exception == nil) { + if (![_delegate respondsToSelector: + @selector(socket:didSendBuffer:length:receiver:)]) + return false; + + _length = [_delegate socket: object + didSendBuffer: &_buffer + length: _length + receiver: &_receiver]; + + return (_length > 0); + } else { + if ([_delegate respondsToSelector: + @selector(socket:didFailToSendWithException:)]) + [_delegate socket: object + didFailToSendWithException: exception]; + + return false; + } # ifdef OF_HAVE_BLOCKS } # endif } @@ -828,16 +839,15 @@ }) } + (void)of_addAsyncConnectForTCPSocket: (OFTCPSocket *)stream mode: (of_run_loop_mode_t)mode - target: (id)target - selector: (SEL)selector + delegate: (id ) + delegate { ADD_WRITE(OFRunLoop_ConnectQueueItem, stream, mode, { - queueItem->_target = [target retain]; - queueItem->_selector = selector; + queueItem->_delegate = [delegate retain]; }) } + (void)of_addAsyncAcceptForTCPSocket: (OFTCPSocket *)stream mode: (of_run_loop_mode_t)mode @@ -850,18 +860,14 @@ + (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)sock buffer: (void *)buffer length: (size_t)length mode: (of_run_loop_mode_t)mode - target: (id)target - selector: (SEL)selector - context: (id)context + delegate: (id )delegate { ADD_READ(OFRunLoop_UDPReceiveQueueItem, sock, mode, { - queueItem->_target = [target retain]; - queueItem->_selector = selector; - queueItem->_context = [context retain]; + queueItem->_delegate = [delegate retain]; queueItem->_buffer = buffer; queueItem->_length = length; }) } @@ -868,18 +874,14 @@ + (void)of_addAsyncSendForUDPSocket: (OFUDPSocket *)sock buffer: (const void *)buffer length: (size_t)length receiver: (of_socket_address_t)receiver mode: (of_run_loop_mode_t)mode - target: (id)target - selector: (SEL)selector - context: (id)context + delegate: (id )delegate { ADD_WRITE(OFRunLoop_UDPSendQueueItem, sock, mode, { - queueItem->_target = [target retain]; - queueItem->_selector = selector; - queueItem->_context = [context retain]; + queueItem->_delegate = [delegate retain]; queueItem->_buffer = buffer; queueItem->_length = length; queueItem->_receiver = receiver; }) } Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -62,11 +62,12 @@ static of_run_loop_mode_t connectRunLoopMode = @"of_tcp_socket_connect_mode"; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; -@interface OFTCPSocket_AsyncConnectContext: OFObject +@interface OFTCPSocket_AsyncConnectContext: OFObject { OFTCPSocket *_socket; OFString *_host; uint16_t _port; OFString *_SOCKS5Host; @@ -104,12 +105,10 @@ SOCKS5Host: (OFString *)SOCKS5Host SOCKS5Port: (uint16_t)SOCKS5Port block: (of_tcp_socket_async_connect_block_t)block; #endif - (void)didConnect; -- (void)socketDidConnect: (OFTCPSocket *)sock - exception: (id)exception; - (void)tryNextAddressWithRunLoopMode: (of_run_loop_mode_t)runLoopMode; - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName socketAddresses: (OFData *)socketAddresses context: (id)context @@ -230,12 +229,12 @@ #ifdef OF_HAVE_BLOCKS } #endif } -- (void)socketDidConnect: (OFTCPSocket *)sock - exception: (id)exception +- (void)of_socketDidConnect: (OF_KINDOF(OFTCPSocket *))sock + exception: (id)exception { if (exception != nil) { if (_socketAddressesIndex >= [_socketAddresses count]) { _exception = [exception retain]; [self didConnect]; @@ -283,16 +282,13 @@ [_socket setBlocking: false]; if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { if (errNo == EINPROGRESS) { - SEL selector = @selector(socketDidConnect:exception:); - [OFRunLoop of_addAsyncConnectForTCPSocket: _socket mode: runLoopMode - target: self - selector: selector]; + delegate: self]; return; } else { [_socket of_closeSocket]; if (_socketAddressesIndex >= [_socketAddresses count]) { Index: src/OFUDPSocket.h ================================================================== --- src/OFUDPSocket.h +++ src/OFUDPSocket.h @@ -64,10 +64,71 @@ typedef size_t (^of_udp_socket_async_send_block_t)(OFUDPSocket *socket, const void *_Nonnull *_Nonnull buffer, size_t bytesSent, of_socket_address_t *_Nonnull receiver, id exception); #endif +/*! + * @protocol OFUDPSocketDelegate OFUDPSocket.h ObjFW/OFUDPSocket.h + * + * @brief A delegate for OFUDPSocket. + */ +@protocol OFUDPSocketDelegate +@optional +/*! + * @brief This method is called when a packet has been received. + * + * @param socket The UDP socket which received a packet + * @param buffer The buffer the packet has been written to + * @param length The length of the packet + * @param sender The address of the sender of the packet + * @return A bool whether the same block should be used for the next receive + */ +- (bool)socket: (OF_KINDOF(OFUDPSocket *))socket + didReceiveIntoBuffer: (void *)buffer + length: (size_t)length + sender: (of_socket_address_t)sender; + +/*! + * @brief This which is called when a packet has been sent. + * + * @param socket The UDP socket which sent a packet + * @param buffer A pointer to the buffer which was sent. This can be changed to + * point to a different buffer to be used on the next send. + * @param length The length of the buffer that has been sent + * @param receiver The receiver for the UDP packet. This may be set to a new + * receiver to which the next packet is sent. + * @return The length to repeat the send with 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. + */ +- (size_t)socket: (OF_KINDOF(OFUDPSocket *))socket + didSendBuffer: (const void *_Nonnull *_Nonnull)buffer + length: (size_t)length + receiver: (of_socket_address_t *_Nonnull)receiver; + +/*! + * @brief This method is called when an exception occurred during an + * asynchronous receive on the socket. + * + * @param socket The socket for which an exception occurred + * @param exception The exception which occurred for the socket + */ +- (void)socket: (OF_KINDOF(OFUDPSocket *))socket + didFailToReceiveWithException: (id)exception; + +/*! + * @brief This method is called when an exception occurred during an + * asynchronous send on the socket. + * + * @param socket The socket for which an exception occurred + * @param exception The exception which occurred for the socket + */ +- (void)socket: (OF_KINDOF(OFUDPSocket *))socket + didFailToSendWithException: (id)exception; +@end + /*! * @class OFUDPSocket OFUDPSocket.h ObjFW/OFUDPSocket.h * * @brief A class which provides methods to create and use UDP sockets. * @@ -91,19 +152,29 @@ of_socket_t _socket; #ifdef OF_WII uint16_t _port; #endif bool _blocking; + id _Nullable _delegate; } /*! * @brief Whether the socket is in blocking mode. * * By default, a socket is in blocking mode. */ @property (nonatomic, getter=isBlocking) bool blocking; +/*! + * @brief The delegate for asynchronous operations on the socket. + * + * @note The delegate is retained for as long as asynchronous operations are + * still outstanding. + */ +@property OF_NULLABLE_PROPERTY (assign, nonatomic) + id delegate; + /*! * @brief Returns a new, autoreleased OFUDPSocket. * * @return A new, autoreleased OFUDPSocket */ @@ -142,26 +213,13 @@ * * 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 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 - target: (id)target - selector: (SEL)selector - context: (nullable id)context; + length: (size_t)length; /*! * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * @@ -168,27 +226,14 @@ * 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; + runLoopMode: (of_run_loop_mode_t)runLoopMode; #ifdef OF_HAVE_BLOCKS /*! * @brief Asynchronously receives a datagram and stores it into the specified * buffer. @@ -247,56 +292,28 @@ * * @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 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 - target: (id)target - selector: (SEL)selector - context: (nullable id)context; + receiver: (of_socket_address_t)receiver; /*! * @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; + runLoopMode: (of_run_loop_mode_t)runLoopMode; #ifdef OF_HAVE_BLOCKS /*! * @brief Asynchronously sends the specified datagram to the specified address. * Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -46,10 +46,12 @@ #import "socket.h" #import "socket_helpers.h" @implementation OFUDPSocket +@synthesize delegate = _delegate; + + (void)initialize { if (self != [OFUDPSocket class]) return; @@ -325,36 +327,25 @@ return ret; } - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length - target: (id)target - selector: (SEL)selector - context: (id)context { [self asyncReceiveIntoBuffer: buffer length: length - runLoopMode: of_run_loop_mode_default - target: target - selector: selector - context: context]; + runLoopMode: of_run_loop_mode_default]; } - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length runLoopMode: (of_run_loop_mode_t)runLoopMode - target: (id)target - selector: (SEL)selector - context: (id)context { [OFRunLoop of_addAsyncReceiveForUDPSocket: self buffer: buffer length: length mode: runLoopMode - target: target - selector: selector - context: context]; + delegate: _delegate]; } #ifdef OF_HAVE_BLOCKS - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length @@ -422,39 +413,28 @@ } - (void)asyncSendBuffer: (const void *)buffer length: (size_t)length receiver: (of_socket_address_t)receiver - target: (id)target - selector: (SEL)selector - context: (id)context { [self asyncSendBuffer: buffer length: length receiver: receiver - runLoopMode: of_run_loop_mode_default - target: target - selector: selector - context: context]; + runLoopMode: of_run_loop_mode_default]; } - (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: (id)context { [OFRunLoop of_addAsyncSendForUDPSocket: self buffer: buffer length: length receiver: receiver mode: runLoopMode - target: target - selector: selector - context: context]; + delegate: _delegate]; } #ifdef OF_HAVE_BLOCKS - (void)asyncSendBuffer: (const void *)buffer length: (size_t)length