summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network/BoostConnection.cpp')
-rw-r--r--Swiften/Network/BoostConnection.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp
index b6b2d9d..1d4bd32 100644
--- a/Swiften/Network/BoostConnection.cpp
+++ b/Swiften/Network/BoostConnection.cpp
@@ -79,11 +79,16 @@ void BoostConnection::disconnect() {
if (writing_) {
closeSocketAfterNextWrite_ = true;
} else {
- socket_.shutdown();
- socket_.close();
+ closeSocket();
}
}
+void BoostConnection::closeSocket() {
+ boost::system::error_code errorCode;
+ socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, errorCode);
+ socket_.close();
+}
+
void BoostConnection::write(const SafeByteArray& data) {
boost::lock_guard<boost::mutex> lock(writeMutex_);
if (!writing_) {
@@ -149,8 +154,7 @@ void BoostConnection::handleDataWritten(const boost::system::error_code& error)
if (writeQueue_.empty()) {
writing_ = false;
if (closeSocketAfterNextWrite_) {
- socket_.shutdown();
- socket_.close();
+ closeSocket();
}
}
else {