   Gethostbyname() doesn't work
  I've been trying to find the problem for 3 hours and It's driving me crazy !!#include <winsock2.h>#pragma comment(lib, "ws2_32.lib")int main(){hostent* HE = gethostbyname("gamedev.net");  if (HE == 0)  {    WSACleanup (); // I get this point..    return 0;  }return 0;}What am I doing wrong ? When I debug, HE gives error: expression cannot be evaluated.I can't sleep because of this -.-btw: I am behind router, but I dont think it will cause a problem.   
  I'm guessing you've just missed out the call to WSAStartup(); in that bit of example code?   ;  Ohhh.. I didn't realize it that it hasn't been initialized in that long code,(I am actually editing something, not creating something new) and I forgot it in my small code.Anyway THANKS I owe you a lot =)   ;Quote:Original post by EralpOhhh.. I didn't realize it that it hasn't been initialized in that long code,(I am actually editing something, not creating something new) and I forgot it in my small code.Anyway THANKS I owe you a lot =)I've been programming in Winsock for years and I still make that mistake all the time. You're not alone. ;)It's good practice to check the Winsock error code (WSAGetLastError()) whenever a Winsock function fails. If you look up the code in the list provided by Microsoft you will generally be able to determine the cause immediately. Trust me, it is a huge help when you run into some obscure error.