示例#1
0
myHostInfo::myHostInfo()
{
#ifdef WIN32
	char sName[HOST_NAME_LENGTH+1];
	memset(sName,0,sizeof(sName));
	gethostname(sName,HOST_NAME_LENGTH);

	try 
	{
		hostPtr = gethostbyname(sName);
		if (hostPtr == NULL)
		{
			int errorCode;
			string errorMsg = "";
			detectErrorGethostbyname(&errorCode,errorMsg);
			myException gethostbynameException(errorCode,errorMsg);
			throw gethostbynameException;
		}
	}
	catch(myException& excp)
	{
		excp.response();
		//std::exit(EXIT_FAILURE);
	}
#else
	openHostDb();
	// winLog<<"UNIX version myHostInfo() is called...\n";
#endif

}
示例#2
0
myHostInfo::myHostInfo()
{

#ifdef UNIX
	openHostDb();
	// winLog<<"UNIX version myHostInfo() is called...\n";
#endif

#ifdef WINDOWS_XP
	
	char sName[HOST_NAME_LENGTH+1];
	memset(sName,0,sizeof(sName));
	gethostname(sName,HOST_NAME_LENGTH);

	try 
	{
		hostPtr = gethostbyname(sName);
		if (hostPtr == NULL)
		{
			int errorCode;
			string errorMsg = "";
			detectErrorGethostbyname(&errorCode,errorMsg);
			myException* gethostbynameException = new myException(errorCode,errorMsg);
			throw gethostbynameException;
		}
	}
	catch(myException* excp)
	{
		excp->response();
		exit(1);
	}
	
#endif

}