Definition at line 62 of file PracticalSocket.cpp. Referenced by CommunicatingSocket::connect(), UDPSocket::sendTo(), and Socket::setLocalAddressAndPort(). 00063 { 00064 memset(&addr, 0, sizeof(addr)); // Zero out address structure 00065 addr.sin_family = AF_INET; // Internet address 00066 00067 hostent *host; // Resolve name 00068 if ((host = gethostbyname(address.c_str())) == NULL) { 00069 // strerror() will not work for gethostbyname() and hstrerror() 00070 // is supposedly obsolete 00071 throw SocketException("Failed to resolve name (gethostbyname())"); 00072 } 00073 addr.sin_addr.s_addr = *((unsigned long *) host->h_addr_list[0]); 00074 00075 addr.sin_port = htons(port); // Assign port in network byte order 00076 }
|