YETI_Result HttpTcpConnector::connect(const HttpUrl & url, HttpClient & client, const HttpProxyAddress * proxy, bool reuse, HttpClient::Connection *& connection) { connection = NULL; const char * server_hostname; YETI_UInt16 server_port; if (proxy) { server_hostname = (const char *)proxy->get_hostname(); server_port = proxy->get_port(); } else { server_hostname = (const char *)url.get_host(); server_port = url.get_port(); } IpAddress address; YETI_CHECK_FINE(address.resolve_name(server_hostname, client.get_config().m_name_resolver_timeout_)); YETI_LOG_FINE_2("TCP connector will connect to %s : %d", server_hostname, server_port); TcpClientSocket * tcp_socket = new TcpClientSocket(); SocketReference socket(tcp_socket, true); tcp_socket->set_read_timeout(client.get_config().m_io_timeout_); tcp_socket->set_write_timeout(client.get_config().m_io_timeout_); SocketAddress socket_address(address, server_port); YETI_CHECK_FINE(tcp_socket->connect(socket_address, client.get_config().m_connection_timeout_)); HttpSimpleConnection * _connection = new HttpSimpleConnection(); _connection->m_socket_ = socket; connection = _connection; tcp_socket->get_input_stream(_connection->m_inputstream_); tcp_socket->get_output_stream(_connection->m_outputstream_); return YETI_SUCCESS; }
int my_send() { printf("==== Send\n"); char * msg = "hello"; UdpSocket sender; DataBuffer buffer(1024); buffer.set_data_size(1024); buffer.set_data((YETI_Byte *)msg, strlen(msg)); IpAddress address; address.resolve_name("localhost"); SocketAddress socket_address(address, 9123); YETI_Result result = sender.send(buffer, &socket_address); if (YETI_FAILED(result)) { fprintf(stderr, "send() failed (%d)\n", result); return result; } return 0; }