diff options
author | Howaner <franzi.moos@googlemail.com> | 2015-01-25 00:34:19 +0100 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2015-01-25 00:34:19 +0100 |
commit | 1eedccc56a1a80b42adbea8dbbe968d42c7fe712 (patch) | |
tree | a5fe3fb72a3c3918b2c4ba413c686f718f5d403c /Tools/ProtoProxy/Server.cpp | |
parent | C++11 and function rename. (diff) | |
parent | Gamosocm support (diff) | |
download | cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.gz cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.bz2 cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.lz cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.xz cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.tar.zst cuberite-1eedccc56a1a80b42adbea8dbbe968d42c7fe712.zip |
Diffstat (limited to '')
-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); |