summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-15 22:47:21 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-15 22:47:21 +0000
commit65ccfccfc1e35a2e65638aea61c46e4e51bd874e (patch)
tree231ccea34d7b44da1c45d8df5b927ddf18859a5c /src/net
parent0d7f2d306d2899571b6034ccd3de6e3a34c2193a (diff)
downloadmana-client-65ccfccfc1e35a2e65638aea61c46e4e51bd874e.tar.gz
mana-client-65ccfccfc1e35a2e65638aea61c46e4e51bd874e.tar.bz2
mana-client-65ccfccfc1e35a2e65638aea61c46e4e51bd874e.tar.xz
mana-client-65ccfccfc1e35a2e65638aea61c46e4e51bd874e.zip
Fixed connection not being shut down completely in case of an error.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/network.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/net/network.cpp b/src/net/network.cpp
index 366d07d9..bd0e2444 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -91,6 +91,7 @@ int networkThread(void *data)
}
Network::Network():
+ mSocket(0),
mAddress(), mPort(0),
mInBuffer(new char[BUFFER_SIZE]),
mOutBuffer(new char[BUFFER_SIZE]),
@@ -154,9 +155,6 @@ bool Network::connect(const std::string &address, short port)
void Network::disconnect()
{
- if (mState != CONNECTED && mState != CONNECTING)
- return;
-
mState = IDLE;
if (mWorkerThread)
@@ -164,7 +162,12 @@ void Network::disconnect()
SDL_WaitThread(mWorkerThread, NULL);
mWorkerThread = NULL;
}
- SDLNet_TCP_Close(mSocket);
+
+ if (mSocket)
+ {
+ SDLNet_TCP_Close(mSocket);
+ mSocket = 0;
+ }
}
void Network::registerHandler(MessageHandler *handler)