diff options
author | Matyas Dolak <dolak@eset.cz> | 2015-01-23 10:10:25 +0100 |
---|---|---|
committer | Matyas Dolak <dolak@eset.cz> | 2015-01-23 10:10:25 +0100 |
commit | 2b75c8905150b06f94df289ef965145b3fe1087f (patch) | |
tree | 2a96b7d91740996f944fcbda96e51761df2b3823 /Tools/ProtoProxy | |
parent | Fixed negative return values in SchematicFileSerializer. (diff) | |
download | cuberite-2b75c8905150b06f94df289ef965145b3fe1087f.tar cuberite-2b75c8905150b06f94df289ef965145b3fe1087f.tar.gz cuberite-2b75c8905150b06f94df289ef965145b3fe1087f.tar.bz2 cuberite-2b75c8905150b06f94df289ef965145b3fe1087f.tar.lz cuberite-2b75c8905150b06f94df289ef965145b3fe1087f.tar.xz cuberite-2b75c8905150b06f94df289ef965145b3fe1087f.tar.zst cuberite-2b75c8905150b06f94df289ef965145b3fe1087f.zip |
Diffstat (limited to 'Tools/ProtoProxy')
-rw-r--r-- | Tools/ProtoProxy/Server.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/Tools/ProtoProxy/Server.cpp b/Tools/ProtoProxy/Server.cpp index bb042b259..9545af852 100644 --- a/Tools/ProtoProxy/Server.cpp +++ b/Tools/ProtoProxy/Server.cpp @@ -38,13 +38,41 @@ int cServer::Init(short a_ListenPort, short a_ConnectPort) m_PublicKeyDER = m_PrivateKey.GetPubKeyDER(); m_ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (m_ListenSocket < 0) + { + #ifdef _WIN32 + int err = WSAGetLastError(); + #else + int err = errno; + #endif + printf("Failed to create listener socket: %d\n", err); + return err; + } sockaddr_in local; memset(&local, 0, sizeof(local)); local.sin_family = AF_INET; - local.sin_addr.s_addr = 0; // All interfaces + local.sin_addr.s_addr = 130; // INADDR_ANY; // All interfaces local.sin_port = htons(a_ListenPort); - bind(m_ListenSocket, (sockaddr *)&local, sizeof(local)); - listen(m_ListenSocket, 1); + if (!bind(m_ListenSocket, (sockaddr *)&local, sizeof(local))) + { + #ifdef _WIN32 + int err = WSAGetLastError(); + #else + int err = errno; + #endif + printf("Failed to bind listener socket: %d\n", err); + return err; + } + if (listen(m_ListenSocket, 1) != 0) + { + #ifdef _WIN32 + int err = WSAGetLastError(); + #else + int err = errno; + #endif + printf("Failed to listen on socket: %d\n", err); + return err; + } printf("Listening on port %d, connecting to localhost:%d\n", a_ListenPort, a_ConnectPort); |