summaryrefslogtreecommitdiffstats
path: root/source/cSocket.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-08 11:02:46 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-08 11:02:46 +0100
commitc82c636d8c9ac24c1e73740c35b3a93525783a3d (patch)
tree45c6bd08dc95ac8509834c35096ced5732db3d7a /source/cSocket.cpp
parentcSocket: final localhost fix - made it a function (forgotten file) (diff)
downloadcuberite-c82c636d8c9ac24c1e73740c35b3a93525783a3d.tar
cuberite-c82c636d8c9ac24c1e73740c35b3a93525783a3d.tar.gz
cuberite-c82c636d8c9ac24c1e73740c35b3a93525783a3d.tar.bz2
cuberite-c82c636d8c9ac24c1e73740c35b3a93525783a3d.tar.lz
cuberite-c82c636d8c9ac24c1e73740c35b3a93525783a3d.tar.xz
cuberite-c82c636d8c9ac24c1e73740c35b3a93525783a3d.tar.zst
cuberite-c82c636d8c9ac24c1e73740c35b3a93525783a3d.zip
Diffstat (limited to '')
-rw-r--r--source/cSocket.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/cSocket.cpp b/source/cSocket.cpp
index 42cc298a7..00f10154b 100644
--- a/source/cSocket.cpp
+++ b/source/cSocket.cpp
@@ -27,6 +27,7 @@ cSocket::cSocket(xSocket a_Socket)
cSocket::~cSocket()
{
+ // Do NOT close the socket; this class is an API wrapper, not a RAII!
}
@@ -100,6 +101,10 @@ AString cSocket::GetErrorString( int a_ErrNo )
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, a_ErrNo, 0, buffer, ARRAYCOUNT(buffer), NULL);
Printf(Out, "%d: %s", a_ErrNo, buffer);
+ if (!Out.empty() && (Out[Out.length() - 1] == '\n'))
+ {
+ Out.erase(Out.length() - 2);
+ }
return Out;
#else // _WIN32
@@ -312,7 +317,7 @@ unsigned short cSocket::GetPort(void) const
{
return 0;
}
- return Addr.sin_port;
+ return ntohs(Addr.sin_port);
}