Overview
Comment: | OFTCPSocket: Implement sync connect via async |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c5c4d38220881a9077f98592c4d525b9 |
User & Date: | js on 2018-10-06 19:36:27 |
Other Links: | manifest | tags |
Context
2018-10-06
| ||
19:41 | OFTCPSocket: -[setBlocking:] on new connections check-in: 02073abe82 user: js tags: trunk | |
19:36 | OFTCPSocket: Implement sync connect via async check-in: c5c4d38220 user: js tags: trunk | |
18:39 | OFSystemInfo: Fix signedness in comparison check-in: 9723036211 user: js tags: trunk | |
Changes
Modified src/Makefile from [a4eb0eb187] to [d620634847].
︙ | ︙ | |||
198 199 200 201 202 203 204 | SRCS_FILES += OFSettings_INIFile.m \ OFURLHandler_file.m SRCS_SOCKETS += OFKernelEventObserver.m \ ${OFKERNELEVENTOBSERVER_EPOLL_M} \ ${OFKERNELEVENTOBSERVER_KQUEUE_M} \ ${OFKERNELEVENTOBSERVER_POLL_M} \ ${OFKERNELEVENTOBSERVER_SELECT_M} \ | < | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | SRCS_FILES += OFSettings_INIFile.m \ OFURLHandler_file.m SRCS_SOCKETS += OFKernelEventObserver.m \ ${OFKERNELEVENTOBSERVER_EPOLL_M} \ ${OFKERNELEVENTOBSERVER_KQUEUE_M} \ ${OFKERNELEVENTOBSERVER_POLL_M} \ ${OFKERNELEVENTOBSERVER_SELECT_M} \ OFURLHandler_HTTP.m OBJS_EXTRA = ${RUNTIME_RUNTIME_A} \ ${EXCEPTIONS_EXCEPTIONS_A} \ ${ENCODINGS_ENCODINGS_A} \ ${FORWARDING_FORWARDING_A} \ ${INVOCATION_INVOCATION_A} |
︙ | ︙ |
Deleted src/OFTCPSocket+SOCKS5.h version [be2dcebc93].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFTCPSocket+SOCKS5.m version [9396f7978b].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFTCPSocket.m from [1071039b7f] to [b569f752f9].
︙ | ︙ | |||
28 29 30 31 32 33 34 | #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFTCPSocket.h" #import "OFTCPSocket+Private.h" | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFTCPSocket.h" #import "OFTCPSocket+Private.h" #import "OFDate.h" #import "OFDNSResolver.h" #import "OFData.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFString.h" #import "OFThread.h" #import "OFTimer.h" |
︙ | ︙ | |||
55 56 57 58 59 60 61 | #import "OFOutOfRangeException.h" #import "OFSetOptionFailedException.h" #import "socket.h" #import "socket_helpers.h" #import "resolver.h" | < < < < < < < > | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #import "OFOutOfRangeException.h" #import "OFSetOptionFailedException.h" #import "socket.h" #import "socket_helpers.h" #import "resolver.h" Class of_tls_socket_class = Nil; 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 { OFTCPSocket *_socket; OFString *_host; uint16_t _port; OFString *_SOCKS5Host; uint16_t _SOCKS5Port; id _target; |
︙ | ︙ | |||
147 148 149 150 151 152 153 | - (bool)socket: (OFTCPSocket *)sock didReadSOCKS5AddressLength: (unsigned char *)addressLength length: (size_t)length context: (id)context exception: (id)exception; @end | > > > > > > > > > > > > | | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | - (bool)socket: (OFTCPSocket *)sock didReadSOCKS5AddressLength: (unsigned char *)addressLength length: (size_t)length context: (id)context exception: (id)exception; @end @interface OFTCPSocket_ConnectContext: OFObject { @public bool _connected; id _exception; } - (void)socketDidConnect: (OFTCPSocket *)sock context: (id)context exception: (id)exception; @end @implementation OFTCPSocket_AsyncConnectContext - (instancetype)initWithSocket: (OFTCPSocket *)sock host: (OFString *)host port: (uint16_t)port SOCKS5Host: (OFString *)SOCKS5Host SOCKS5Port: (uint16_t)SOCKS5Port target: (id)target selector: (SEL)selector |
︙ | ︙ | |||
631 632 633 634 635 636 637 638 639 640 641 642 643 644 | target: self selector: @selector(socket:didReadSOCKS5Address: length:context:exception:) context: nil]; return false; } @end @implementation OFTCPSocket @synthesize SOCKS5Host = _SOCKS5Host, SOCKS5Port = _SOCKS5Port; + (void)setSOCKS5Host: (OFString *)host { id old = defaultSOCKS5Host; | > > > > > > > > > > > > > > > > > > > | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | target: self selector: @selector(socket:didReadSOCKS5Address: length:context:exception:) context: nil]; return false; } @end @implementation OFTCPSocket_ConnectContext - (void)dealloc { [_exception release]; [super dealloc]; } - (void)socketDidConnect: (OFTCPSocket *)sock context: (id)context exception: (id)exception { if (exception != nil) _exception = [exception retain]; _connected = true; } @end @implementation OFTCPSocket @synthesize SOCKS5Host = _SOCKS5Host, SOCKS5Port = _SOCKS5Port; + (void)setSOCKS5Host: (OFString *)host { id old = defaultSOCKS5Host; |
︙ | ︙ | |||
739 740 741 742 743 744 745 | return errNo; } - (void)connectToHost: (OFString *)host port: (uint16_t)port { | < < < < | | | | < < < < | | < | < < < | < < < < < < < < < < < | < | > < < < | | < < < | < < < | < < < < | < | | | | < | < < < < < < < < > | 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | return errNo; } - (void)connectToHost: (OFString *)host port: (uint16_t)port { void *pool = objc_autoreleasePoolPush(); OFTCPSocket_ConnectContext *context = [[[OFTCPSocket_ConnectContext alloc] init] autorelease]; OFRunLoop *runLoop = [OFRunLoop currentRunLoop]; [self asyncConnectToHost: host port: port runLoopMode: connectRunLoopMode target: context selector: @selector(socketDidConnect:context:exception:) context: nil]; while (!context->_connected) [runLoop runMode: connectRunLoopMode beforeDate: nil]; /* Cleanup */ [runLoop runMode: connectRunLoopMode beforeDate: [OFDate date]]; if (context->_exception != nil) @throw context->_exception; objc_autoreleasePoolPop(pool); } - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port target: (id)target selector: (SEL)selector context: (id)context |
︙ | ︙ | |||
833 834 835 836 837 838 839 | runLoopMode: (of_run_loop_mode_t)runLoopMode target: (id)target selector: (SEL)selector context: (id)context { void *pool = objc_autoreleasePoolPush(); | | | 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | runLoopMode: (of_run_loop_mode_t)runLoopMode target: (id)target selector: (SEL)selector context: (id)context { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_AsyncConnectContext alloc] initWithSocket: self host: host port: port SOCKS5Host: _SOCKS5Host SOCKS5Port: _SOCKS5Port target: target selector: selector |
︙ | ︙ | |||
865 866 867 868 869 870 871 | - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (of_run_loop_mode_t)runLoopMode block: (of_tcp_socket_async_connect_block_t)block { void *pool = objc_autoreleasePoolPush(); | | | 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (of_run_loop_mode_t)runLoopMode block: (of_tcp_socket_async_connect_block_t)block { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_AsyncConnectContext alloc] initWithSocket: self host: host port: port SOCKS5Host: _SOCKS5Host SOCKS5Port: _SOCKS5Port block: block] autorelease] startWithRunLoopMode: runLoopMode]; |
︙ | ︙ |