Differences From Artifact [4724c73932]:
- File
src/OFTCPSocket.m
— part of check-in
[9ddd33a258]
at
2013-01-12 17:29:24
on branch trunk
— Rename *UsingEncoding: to *WithEncoding:.
This reverts 5362941.
Even though *UsingEncoding: is what Foundation uses, *WithEncoding: is
more natural and is more consistent with the rest. Also, this means this
restores it to the API of 0.7. (user: js, size: 15860) [annotate] [blame] [check-ins using]
To Artifact [e458e43209]:
- File src/OFTCPSocket.m — part of check-in [85b8efadbc] at 2013-01-12 20:21:17 on branch trunk — Fix --disable-threads. (user: js, size: 15950) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
31 32 33 34 35 36 37 | # include <arpa/inet.h> # include <netdb.h> #endif #import "OFTCPSocket.h" #import "OFTCPSocket+SOCKS5.h" #import "OFString.h" | > | > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # include <arpa/inet.h> # include <netdb.h> #endif #import "OFTCPSocket.h" #import "OFTCPSocket+SOCKS5.h" #import "OFString.h" #ifdef OF_THREADS # import "OFThread.h" #endif #import "OFTimer.h" #import "OFRunLoop.h" #import "OFAcceptFailedException.h" #import "OFAlreadyConnectedException.h" #import "OFAddressTranslationFailedException.h" #import "OFBindFailedException.h" |
︙ | ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | } Class of_tls_socket_class = Nil; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; @interface OFTCPSocket_ConnectThread: OFThread { OFThread *sourceThread; OFTCPSocket *sock; OFString *host; uint16_t port; id target; SEL selector; | > | | | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | } Class of_tls_socket_class = Nil; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; #ifdef OF_THREADS @interface OFTCPSocket_ConnectThread: OFThread { OFThread *sourceThread; OFTCPSocket *sock; OFString *host; uint16_t port; id target; SEL selector; # ifdef OF_HAVE_BLOCKS of_tcpsocket_async_connect_block_t connectBlock; # endif OFException *exception; } - initWithSourceThread: (OFThread*)sourceThread socket: (OFTCPSocket*)socket host: (OFString*)host port: (uint16_t)port target: (id)target selector: (SEL)selector; # ifdef OF_HAVE_BLOCKS - initWithSourceThread: (OFThread*)sourceThread socket: (OFTCPSocket*)socket host: (OFString*)host port: (uint16_t)port block: (of_tcpsocket_async_connect_block_t)block; # endif @end @implementation OFTCPSocket_ConnectThread - initWithSourceThread: (OFThread*)sourceThread_ socket: (OFTCPSocket*)sock_ host: (OFString*)host_ port: (uint16_t)port_ |
︙ | ︙ | |||
129 130 131 132 133 134 135 | [self release]; @throw e; } return self; } | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | [self release]; @throw e; } return self; } # ifdef OF_HAVE_BLOCKS - initWithSourceThread: (OFThread*)sourceThread_ socket: (OFTCPSocket*)sock_ host: (OFString*)host_ port: (uint16_t)port_ block: (of_tcpsocket_async_connect_block_t)block_ { self = [super init]; |
︙ | ︙ | |||
151 152 153 154 155 156 157 | } @catch (id e) { [self release]; @throw e; } return self; } | | | | | | | | | 154 155 156 157 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 188 189 190 191 192 193 194 195 196 197 198 199 200 | } @catch (id e) { [self release]; @throw e; } return self; } # endif - (void)dealloc { [sourceThread release]; [sock release]; [host release]; [target release]; # ifdef OF_HAVE_BLOCKS [connectBlock release]; # endif [exception release]; [super dealloc]; } - (void)didConnect { [self join]; # ifdef OF_HAVE_BLOCKS if (connectBlock != NULL) connectBlock(sock, exception); else { # endif void (*func)(id, SEL, OFTCPSocket*, OFException*) = (void(*)(id, SEL, OFTCPSocket*, OFException*))[target methodForSelector: selector]; func(target, selector, sock, exception); # ifdef OF_HAVE_BLOCKS } # endif } - (id)main { void *pool = objc_autoreleasePoolPush(); @try { |
︙ | ︙ | |||
206 207 208 209 210 211 212 213 214 215 216 217 218 219 | waitUntilDone: NO]; objc_autoreleasePoolPop(pool); return nil; } @end @implementation OFTCPSocket #if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) + (void)initialize { if (self == [OFTCPSocket class]) mutex = [[OFMutex alloc] init]; | > | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | waitUntilDone: NO]; objc_autoreleasePoolPop(pool); return nil; } @end #endif @implementation OFTCPSocket #if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) + (void)initialize { if (self == [OFTCPSocket class]) mutex = [[OFMutex alloc] init]; |
︙ | ︙ | |||
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | port: port]; if (SOCKS5Host != nil) [self OF_SOCKS5ConnectToHost: destinationHost port: destinationPort]; } - (void)asyncConnectToHost: (OFString*)host port: (uint16_t)port target: (id)target selector: (SEL)selector { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_ConnectThread alloc] initWithSourceThread: [OFThread currentThread] socket: self host: host port: port target: target selector: selector] autorelease] start]; objc_autoreleasePoolPop(pool); } | > | > | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | port: port]; if (SOCKS5Host != nil) [self OF_SOCKS5ConnectToHost: destinationHost port: destinationPort]; } #ifdef OF_THREADS - (void)asyncConnectToHost: (OFString*)host port: (uint16_t)port target: (id)target selector: (SEL)selector { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_ConnectThread alloc] initWithSourceThread: [OFThread currentThread] socket: self host: host port: port target: target selector: selector] autorelease] start]; objc_autoreleasePoolPop(pool); } # ifdef OF_HAVE_BLOCKS - (void)asyncConnectToHost: (OFString*)host port: (uint16_t)port block: (of_tcpsocket_async_connect_block_t)block { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_ConnectThread alloc] initWithSourceThread: [OFThread currentThread] socket: self host: host port: port block: block] autorelease] start]; objc_autoreleasePoolPop(pool); } # endif #endif - (uint16_t)bindToHost: (OFString*)host port: (uint16_t)port { const int one = 1; union { |
︙ | ︙ |