Hey, I was just wondering why when gethostbyname()'s return value is assigned to a LPHOSTENT structure, using gethostbyname() one more time reassigns that original variable, regardless of whether or not you told it to?
One would think that client.sin_addr would point to the IP of microsoft.com. It doesn't. It points to cnn.com....which makes absolutely no sense at all. I've tested this several times and it's always the same. WHY? I'm using MSVC++ 6.Code:LPHOSTENT lphost = NULL; LPHOSTENT lphost2 = NULL; //assign lphost to the IP at www.microsoft.com lphost = gethostbyname("www.microsoft.com"); //assign a different var, lphost2, to www.cnn.com lphost2 = gethostbyname("www.cnn.com"); //Assign to the address of lphost... client.sin_addr = *((LPIN_ADDR)*lphost->h_addr_list);