コード例 #1
0
ファイル: nd_tcp.c プロジェクト: neil78duan/ndnetsdk
//connect remote host
int nd_tcpnode_connect(const char *host, int port, struct nd_tcp_node *node, struct nd_proxy_info *proxy)
{
	ENTER_FUNC()
		nd_assert(node);
	nd_assert(host);

	node->sys_error = 0;
	node->last_push = nd_time();
	ndlbuf_reset(&(node->recv_buffer));		/* buffer store data recv from net */
	ndlbuf_reset(&(node->send_buffer));		/* buffer store data send from net */

	if (proxy && proxy->proxy_type != ND_PROXY_NOPROXY) {
		node->fd = nd_proxy_connect(host, port, &(node->remote_addr), proxy, 0);
	}
	else {
		node->fd = nd_socket_tcp_connect(host, (short)port, &(node->remote_addr));
	}

	if (node->fd <= 0) {
		node->myerrno = NDERR_OPENFILE;
		LEAVE_FUNC();
		return -1;
	}
	TCPNODE_SET_OK(node);
	nd_socket_nonblock(node->fd, 1);
	_set_ndtcp_conn_dft_option(node->fd);
	node->start_time = nd_time();
	if (node->remote_addr.sin_family == AF_INET6) {
		node->is_ipv6 = 1;
	}
	LEAVE_FUNC();
	return 0;
}
コード例 #2
0
void NDHttpRequest::Reset()
{
	ndlbuf_reset(&m_recvBuf) ;
	m_parseStat = 0;
	m_parseProgress = 0 ;
	m_header.clear();
	m_body.clear() ;
	m_httpProtocol.clear();
}