Differences From Artifact [94bf69c96d]:
- File src/OFTCPSocket.m — part of check-in [0509d7a844] at 2019-01-03 19:13:03 on branch trunk — Update copyright (user: js, size: 25450) [annotate] [blame] [check-ins using]
To Artifact [909cd558d8]:
- File
src/OFTCPSocket.m
— part of check-in
[ab89c47f42]
at
2019-01-07 22:59:58
on branch trunk
— Partially fix sockets on Nintendo 3DS/Wii
This does not fully fix it yet, but at least the socket tests in the
test suite pass on 3DS now. (user: js, size: 26095) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | return; } [self tryNextAddressWithRunLoopMode: runLoopMode]; return; } [_socket setBlocking: false]; if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { if (errNo == EINPROGRESS) { [OFRunLoop of_addAsyncConnectForTCPSocket: _socket mode: runLoopMode delegate: self]; return; } else { [_socket of_closeSocket]; if (_socketAddressesIndex >= [_socketAddresses count]) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; [self didConnect]; return; } [self tryNextAddressWithRunLoopMode: runLoopMode]; return; } } [self didConnect]; } - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName socketAddresses: (OFData *)socketAddresses | > > > > > > > > > > > > > > > > > > > > > > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | return; } [self tryNextAddressWithRunLoopMode: runLoopMode]; return; } #if defined(OF_NINTENDO_3DS) || defined(OF_WII) /* * On Wii and 3DS, connect() fails if non-blocking is enabled. * * Additionally, on Wii, there is no getsockopt(), so it would not be * possible to get the error (or success) after connecting anyway. * * So for now, connecting is blocking on Wii and 3DS. * * FIXME: Use a different thread as a work around. */ [_socket setBlocking: true]; #else [_socket setBlocking: false]; #endif if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { #if !defined(OF_NINTENDO_3DS) && !defined(OF_WII) if (errNo == EINPROGRESS) { [OFRunLoop of_addAsyncConnectForTCPSocket: _socket mode: runLoopMode delegate: self]; return; } else { #endif [_socket of_closeSocket]; if (_socketAddressesIndex >= [_socketAddresses count]) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; [self didConnect]; return; } [self tryNextAddressWithRunLoopMode: runLoopMode]; return; #if !defined(OF_NINTENDO_3DS) && !defined(OF_WII) } #endif } #if defined(OF_NINTENDO_3DS) || defined(OF_WII) [_socket setBlocking: false]; #endif [self didConnect]; } - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName socketAddresses: (OFData *)socketAddresses |
︙ | ︙ | |||
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | - (void)of_closeSocket { closesocket(_socket); _socket = INVALID_SOCKET; } - (int)of_socketError { int errNo; socklen_t len = sizeof(errNo); if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char *)&errNo, &len) != 0) return of_socket_errno(); return errNo; } - (void)connectToHost: (OFString *)host port: (uint16_t)port { void *pool = objc_autoreleasePoolPush(); id <OFTCPSocketDelegate> delegate = [_delegate retain]; OFTCPSocket_ConnectDelegate *connectDelegate = | > > | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | - (void)of_closeSocket { closesocket(_socket); _socket = INVALID_SOCKET; } #ifndef OF_WII - (int)of_socketError { int errNo; socklen_t len = sizeof(errNo); if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char *)&errNo, &len) != 0) return of_socket_errno(); return errNo; } #endif - (void)connectToHost: (OFString *)host port: (uint16_t)port { void *pool = objc_autoreleasePoolPush(); id <OFTCPSocketDelegate> delegate = [_delegate retain]; OFTCPSocket_ConnectDelegate *connectDelegate = |
︙ | ︙ |