#include "stdafx.h"
/*
#include "Internet_time.h"

typedef boost::asio::ip::tcp tcp;

bool fGetInternetTime(char *vTime)
{
    try
	{
		if (vTime == NULL)
		{
			return FALSE;
		}
		boost::asio::io_service io;
        tcp::resolver resolver(io);
        tcp::socket sock(io);
        boost::system::error_code err;
        tcp::resolver::query q("time.nist.gov","daytime");
        tcp::resolver::iterator it = resolver.resolve(q, err), itEnd;
		if (err) throw boost::system::system_error(err);
        err = boost::asio::error::host_not_found;
        while (err && it != itEnd)
        {
            sock.close();
            sock.connect(*it++, err);
        }
        if (err)
        {
            //std::cerr<<"connect() failed\n";
            return FALSE;
        }
        char buf[256];
        std::size_t len = 0;
		do
        {
            len += sock.read_some(boost::asio::buffer(buf + len, sizeof(buf) - len), err);
        } while(!err);
        int vPos1, vPos2, vPos3;
		vPos1 = 0;
		vPos2 = 0;
		vPos3 = 0;
		for (int vvi = 0; vvi < len; vvi++)
		{
			if (buf[vvi] == ' ')
			{
				if (vPos1 == 0)
				{
					vPos1 = vvi;
					goto m2;
				}
				if (vPos2 == 0)
				{
					vPos2 = vvi;
					goto m2;
				}
				if (vPos3 == 0)
				{
					vPos3 = vvi;
					break;
				}
			}
m2:;
		}
		if (vPos1 == 0 || vPos2 == 0 || vPos3 == 0)
		{
			goto m3;
		}
		char buf2[3];
		buf2[0] = buf[vPos2+1];
		buf2[1] = buf[vPos2+2];
		buf2[2] = '\0';
		int v1 = atoi(buf2);
		v1 += 3;
		buf[vPos2+1] = '\0';
		buf[vPos3] = '\0';
		sprintf(vTime,"%s%d%s",buf+vPos1+1,v1,buf+vPos2+3);
        //std::cout.write(buf, strlen(buf));
m3:
        sock.shutdown(tcp::socket::shutdown_both);
        sock.close();
    }
    catch (...)
    {
		return FALSE;
    }
	if (strlen(vTime) != 8 + 1 + 8)
	{
		return FALSE;
	}
    return TRUE;
}

bool fGetIpAddress(char *vIP, char *vHost)
{
	if (vIP == NULL || vHost == NULL) return FALSE;
	if (strlen(vHost) <= 0) return FALSE;
    try
	{
        boost::asio::io_service io;
        tcp::resolver resolver(io);
        tcp::socket sock(io);
        boost::system::error_code err;
        tcp::resolver::query q(vHost,"");
        tcp::resolver::iterator it = resolver.resolve(q, err), itEnd;
        if (err) throw boost::system::system_error(err);
        err = boost::asio::error::host_not_found;
        while (err && it != itEnd)
        {
            boost::asio::ip::address addr=(it++)->endpoint().address();
			sprintf(vIP,"%s\0",addr.to_string().c_str());
        }
    }
    catch (...)
    {
		return FALSE;
    }
    return TRUE;
}*/