summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/Socket.cpp
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-11-24 15:37:03 +0100
committerAlexander Harkness <bearbin@gmail.com>2013-11-24 15:37:03 +0100
commitc3cd436ec3526962f0f0698ab2d75774247c340b (patch)
treeaf5fa89e891ede194f981399af8b830afc6dec97 /src/OSSupport/Socket.cpp
parentRemoved pedantic build and added optimisation to debug builds. (diff)
parentRCONClient: Initial implementation. (diff)
downloadcuberite-c3cd436ec3526962f0f0698ab2d75774247c340b.tar
cuberite-c3cd436ec3526962f0f0698ab2d75774247c340b.tar.gz
cuberite-c3cd436ec3526962f0f0698ab2d75774247c340b.tar.bz2
cuberite-c3cd436ec3526962f0f0698ab2d75774247c340b.tar.lz
cuberite-c3cd436ec3526962f0f0698ab2d75774247c340b.tar.xz
cuberite-c3cd436ec3526962f0f0698ab2d75774247c340b.tar.zst
cuberite-c3cd436ec3526962f0f0698ab2d75774247c340b.zip
Diffstat (limited to 'src/OSSupport/Socket.cpp')
-rw-r--r--src/OSSupport/Socket.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp
index 48b5d704d..c461d38a4 100644
--- a/src/OSSupport/Socket.cpp
+++ b/src/OSSupport/Socket.cpp
@@ -169,7 +169,7 @@ bool cSocket::SetReuseAddress(void)
-int cSocket::WSAStartup()
+int cSocket::WSAStartup(void)
{
#ifdef _WIN32
WSADATA wsaData;
@@ -336,23 +336,23 @@ bool cSocket::ConnectIPv4(const AString & a_HostNameOrAddr, unsigned short a_Por
{
// First try IP Address string to hostent conversion, because it's faster
unsigned long addr = inet_addr(a_HostNameOrAddr.c_str());
- hostent * hp = gethostbyaddr((char*)&addr, sizeof(addr), AF_INET);
- if (hp == NULL)
+ if (addr == INADDR_NONE)
{
// It is not an IP Address string, but rather a regular hostname, resolve:
- hp = gethostbyname(a_HostNameOrAddr.c_str());
+ hostent * hp = gethostbyname(a_HostNameOrAddr.c_str());
if (hp == NULL)
{
- LOGWARN("cTCPLink: Could not resolve hostname \"%s\"", a_HostNameOrAddr.c_str());
+ LOGWARNING("%s: Could not resolve hostname \"%s\"", __FUNCTION__, a_HostNameOrAddr.c_str());
CloseSocket();
return false;
}
+ addr = *((unsigned long*)hp->h_addr);
}
sockaddr_in server;
- server.sin_addr.s_addr = *((unsigned long*)hp->h_addr);
+ server.sin_addr.s_addr = addr;
server.sin_family = AF_INET;
- server.sin_port = htons( (unsigned short)a_Port );
+ server.sin_port = htons((unsigned short)a_Port);
return (connect(m_Socket, (sockaddr *)&server, sizeof(server)) == 0);
}