@@ -49,10 +49,11 @@ OFThread *_sourceThread; OFString *_host; uint16_t _port; id _target; SEL _selector; + id _context; # ifdef OF_HAVE_BLOCKS of_udp_socket_async_resolve_block_t _block; # endif of_udp_socket_address_t _address; OFException *_exception; @@ -60,11 +61,12 @@ - initWithSourceThread: (OFThread *)sourceThread host: (OFString *)host port: (uint16_t)port target: (id)target - selector: (SEL)selector; + selector: (SEL)selector + context: (id)context; # ifdef OF_HAVE_BLOCKS - initWithSourceThread: (OFThread *)sourceThread host: (OFString *)host port: (uint16_t)port block: (of_udp_socket_async_resolve_block_t)block; @@ -75,19 +77,21 @@ - initWithSourceThread: (OFThread *)sourceThread host: (OFString *)host port: (uint16_t)port target: (id)target selector: (SEL)selector + context: (id)context { self = [super init]; @try { _sourceThread = [sourceThread retain]; _host = [host retain]; _port = port; _target = [target retain]; _selector = selector; + _context = [context retain]; } @catch (id e) { [self release]; @throw e; } @@ -119,10 +123,11 @@ - (void)dealloc { [_sourceThread release]; [_host release]; [_target release]; + [_context release]; # ifdef OF_HAVE_BLOCKS [_block release]; # endif [_exception release]; @@ -137,16 +142,17 @@ if (_block != NULL) _block(_host, _port, _address, _exception); else { # endif void (*func)(id, SEL, OFString *, uint16_t, - of_udp_socket_address_t, OFException *) = + of_udp_socket_address_t, id, OFException *) = (void (*)(id, SEL, OFString *, uint16_t, - of_udp_socket_address_t, OFException *))[_target - methodForSelector: _selector]; + of_udp_socket_address_t, id, OFException *)) + [_target methodForSelector: _selector]; - func(_target, _selector, _host, _port, _address, _exception); + func(_target, _selector, _host, _port, _address, _context, + _exception); # ifdef OF_HAVE_BLOCKS } # endif } @@ -321,19 +327,21 @@ #ifdef OF_HAVE_THREADS + (void)asyncResolveAddressForHost: (OFString *)host port: (uint16_t)port target: (id)target selector: (SEL)selector + context: (id)context { void *pool = objc_autoreleasePoolPush(); [[[[OFUDPSocket_ResolveThread alloc] initWithSourceThread: [OFThread currentThread] host: host port: port target: target - selector: selector] autorelease] start]; + selector: selector + context: context] autorelease] start]; objc_autoreleasePoolPop(pool); } # ifdef OF_HAVE_BLOCKS @@ -558,16 +566,18 @@ - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length target: (id)target selector: (SEL)selector + context: (id)context { [OFRunLoop of_addAsyncReceiveForUDPSocket: self buffer: buffer length: length target: target - selector: selector]; + selector: selector + context: context]; } #ifdef OF_HAVE_BLOCKS - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length