Commit 24c216be authored by Fluorohydride's avatar Fluorohydride

Merge pull request #532 from matteoserva/master

hostnames supported in lan mode
parents 5a0227dc 1252ad89
......@@ -37,7 +37,28 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
while(*pstr && i < 16)
ip[i++] = *pstr++;
ip[i] = 0;
unsigned int remote_addr = htonl(inet_addr(ip));
struct addrinfo hints, *servinfo;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET; /* Allow IPv4 or IPv6 */
hints.ai_socktype = SOCK_STREAM; /* Datagram socket */
hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
hints.ai_protocol = 0; /* Any protocol */
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL;
int status;
char hostname[100];
BufferIO::CopyWStr((wchar_t *)mainGame->ebJoinIP->getText(),hostname,100);
if ((status = getaddrinfo(hostname, NULL, &hints, &servinfo)) == -1) {
//fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status));
//error handling
}
else
{
inet_ntop(AF_INET, &(((struct sockaddr_in *)servinfo->ai_addr)->sin_addr), ip, 20);
}
unsigned int remote_addr = htonl(inet_addr(ip));
unsigned int remote_port = _wtoi(mainGame->ebJoinPort->getText());
BufferIO::CopyWStr(mainGame->ebJoinIP->getText(), mainGame->gameConf.lastip, 20);
BufferIO::CopyWStr(mainGame->ebJoinPort->getText(), mainGame->gameConf.lastport, 20);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment