@@ -361,14 +361,16 @@ context: nil]; } - (void)sendSOCKS5Request { + OFData *data = [OFData dataWithItems: "\x05\x01\x00" + count: 3]; + _SOCKS5State = SOCKS5_STATE_SEND_AUTHENTICATION; - [_socket asyncWriteBuffer: "\x05\x01\x00" - length: 3 - runLoopMode: [[OFRunLoop currentRunLoop] currentMode]]; + [_socket asyncWriteData: data + runLoopMode: [[OFRunLoop currentRunLoop] currentMode]]; } - (bool)stream: (OF_KINDOF(OFStream *))sock didReadIntoBuffer: (void *)buffer length: (size_t)length @@ -417,13 +419,12 @@ port[1] = _port & 0xFF; [_request addItems: port count: 2]; _SOCKS5State = SOCKS5_STATE_SEND_REQUEST; - [_socket asyncWriteBuffer: [_request items] - length: [_request count] - runLoopMode: runLoopMode]; + [_socket asyncWriteData: _request + runLoopMode: runLoopMode]; return false; case SOCKS5_STATE_READ_RESPONSE: response = buffer; if (response[0] != 5 || response[2] != 0) { @@ -521,21 +522,21 @@ assert(0); return false; } } -- (size_t)stream: (OF_KINDOF(OFStream *))sock - didWriteBuffer: (const void **)buffer - length: (size_t)length - exception: (id)exception +- (OFData *)stream: (OF_KINDOF(OFStream *))sock + didWriteData: (OFData *)data + bytesWritten: (size_t)bytesWritten + exception: (id)exception { of_run_loop_mode_t runLoopMode; if (exception != nil) { _exception = [exception retain]; [self didConnect]; - return 0; + return nil; } runLoopMode = [[OFRunLoop currentRunLoop] currentMode]; switch (_SOCKS5State) { @@ -542,23 +543,23 @@ case SOCKS5_STATE_SEND_AUTHENTICATION: _SOCKS5State = SOCKS5_STATE_READ_VERSION; [_socket asyncReadIntoBuffer: _buffer exactLength: 2 runLoopMode: runLoopMode]; - return 0; + return nil; case SOCKS5_STATE_SEND_REQUEST: [_request release]; _request = nil; _SOCKS5State = SOCKS5_STATE_READ_RESPONSE; [_socket asyncReadIntoBuffer: _buffer exactLength: 4 runLoopMode: runLoopMode]; - return 0; + return nil; default: assert(0); - return 0; + return nil; } } @end @implementation OFTCPSocket_ConnectDelegate