summaryrefslogtreecommitdiff
path: root/src/network/core/tcp.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-02-12 21:09:34 +0000
committerrubidium <rubidium@openttd.org>2011-02-12 21:09:34 +0000
commitadfd64803108b0f418a5f5cb4ea96b25d2eaa45c (patch)
tree8499c1ad40825fb458503fe9f84c7e97dc2ba691 /src/network/core/tcp.cpp
parent92d0d6d10b815700e72869e87da044ffafd1c9bb (diff)
downloadopenttd-adfd64803108b0f418a5f5cb4ea96b25d2eaa45c.tar.xz
(svn r22068) -Codechange/Fix: return "connection lost" instead of "okay" when SendPackets closed the connection
Diffstat (limited to 'src/network/core/tcp.cpp')
-rw-r--r--src/network/core/tcp.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp
index 66f19107c..9a6704006 100644
--- a/src/network/core/tcp.cpp
+++ b/src/network/core/tcp.cpp
@@ -90,14 +90,14 @@ void NetworkTCPSocketHandler::SendPacket(Packet *packet)
* @return \c true if a (part of a) packet could be sent and
* the connection is not closed yet.
*/
-bool NetworkTCPSocketHandler::SendPackets(bool closing_down)
+SendPacketsState NetworkTCPSocketHandler::SendPackets(bool closing_down)
{
ssize_t res;
Packet *p;
/* We can not write to this socket!! */
- if (!this->writable) return false;
- if (!this->IsConnected()) return false;
+ if (!this->writable) return SPS_NONE_SENT;
+ if (!this->IsConnected()) return SPS_CLOSED;
p = this->packet_queue;
while (p != NULL) {
@@ -110,14 +110,14 @@ bool NetworkTCPSocketHandler::SendPackets(bool closing_down)
DEBUG(net, 0, "send failed with error %d", err);
this->CloseConnection();
}
- return false;
+ return SPS_CLOSED;
}
- return true;
+ return SPS_PARTLY_SENT;
}
if (res == 0) {
/* Client/server has left us :( */
if (!closing_down) this->CloseConnection();
- return false;
+ return SPS_CLOSED;
}
p->pos += res;
@@ -129,11 +129,11 @@ bool NetworkTCPSocketHandler::SendPackets(bool closing_down)
delete p;
p = this->packet_queue;
} else {
- return true;
+ return SPS_PARTLY_SENT;
}
}
- return true;
+ return SPS_ALL_SENT;
}
/**
@@ -216,11 +216,6 @@ Packet *NetworkTCPSocketHandler::ReceivePacket()
return p;
}
-bool NetworkTCPSocketHandler::IsPacketQueueEmpty()
-{
- return this->packet_queue == NULL;
-}
-
/**
* Check whether this socket can send or receive something.
* @return \c true when there is something to receive.