From: "Alex Vinokur" <ale...@users.sourceforge.net>
Date: Thu, 26 Jan 2006 05:12:12 -0800
Local: Thurs, Jan 26 2006 8:12 am
Subject: Usage of gethostbyname()
// ==========================
// Usage of gethostbyname() // Language: C++ // Microsoft Windows XP Professional // Microsoft C++ Compiler Version 13.10.3077 for 80x86 // ========================== // -------------------- // -------------------- // -------------------- // ==================== // ==================== // ==================== return string (host_name); } // ==================== vector<vector<string> > get_hostbyname(const string& host_name_i = string()) { const hostent * const p_host = gethostbyname (host_name_i.c_str()); if (p_host == 0) { CERR << "" << "Unable to perform gethostbyname(" << host_name_i << "): " << "h_errno = " << h_errno << ", " << "WSAGetLastError() = " << WSAGetLastError() << " - " << strerror(WSAGetLastError()) ; return vector<vector<string> > (); } vector<vector<string> > ret_vvect (SIZE_OF_HOSTBYNAME_INFO); ret_vvect[H_NAME].push_back (p_host->h_name); for (int i = 0; p_host->h_aliases[i]; i++) return ret_vvect; } // ==================== void show_hostbyname(const string& host_name_i = string()) { cout << endl; cout << endl; cout << "====== " << "gethostbyname(" << host_name_i << ")" << " ======" << endl; const vector<vector<string> > result = get_hostbyname (host_name_i); for (size_t i = 0; i < result.size(); i++) } // ==================== int main () { WSADATA wsaData; WSAStartup(MAKEWORD(2,2), &wsaData); int ret_code; // -------------------- show_hostbyname ("localhost"); if (!host_name.empty()) WSACleanup(); return 0; } Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||