summaryrefslogtreecommitdiffstats
path: root/tests/Network
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-01-12 14:58:52 +0100
committerMattes D <github@xoft.cz>2015-01-22 20:12:49 +0100
commitd8ac99a0374b528caca66ad8ecb5fb36f6334e77 (patch)
tree337f48c5e77435c740cb710ee255358d16c28c14 /tests/Network
parentcNetwork: Fixed Linux compilation. (diff)
downloadcuberite-d8ac99a0374b528caca66ad8ecb5fb36f6334e77.tar
cuberite-d8ac99a0374b528caca66ad8ecb5fb36f6334e77.tar.gz
cuberite-d8ac99a0374b528caca66ad8ecb5fb36f6334e77.tar.bz2
cuberite-d8ac99a0374b528caca66ad8ecb5fb36f6334e77.tar.lz
cuberite-d8ac99a0374b528caca66ad8ecb5fb36f6334e77.tar.xz
cuberite-d8ac99a0374b528caca66ad8ecb5fb36f6334e77.tar.zst
cuberite-d8ac99a0374b528caca66ad8ecb5fb36f6334e77.zip
Diffstat (limited to 'tests/Network')
-rw-r--r--tests/Network/EchoServer.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/Network/EchoServer.cpp b/tests/Network/EchoServer.cpp
index 3d9a6228d..1e0ac023f 100644
--- a/tests/Network/EchoServer.cpp
+++ b/tests/Network/EchoServer.cpp
@@ -38,6 +38,16 @@ class cEchoLinkCallbacks:
LOGD("%p (%s:%d): Data received (%u bytes), echoing back.", &a_Link, a_Link.GetRemoteIP().c_str(), a_Link.GetRemotePort(), static_cast<unsigned>(a_Size));
a_Link.Send(a_Data, a_Size);
LOGD("Echo queued");
+
+ // Search for a Ctrl+Z, if found, drop the connection:
+ for (size_t i = 0; i < a_Size; i++)
+ {
+ if (a_Data[i] == '\x1a')
+ {
+ a_Link.Close();
+ return;
+ }
+ }
}
virtual void OnRemoteClosed(cTCPLink & a_Link) override
@@ -67,7 +77,7 @@ int main()
ASSERT(Server->IsListening());
// Wait for the user to terminate the server:
- printf("Press enter to terminate the server.\n");
+ printf("Press enter to close the server.\n");
AString line;
std::getline(std::cin, line);
@@ -75,6 +85,10 @@ int main()
LOG("Server terminating.");
Server->Close();
ASSERT(!Server->IsListening());
+ LOGD("Server has been closed.");
+
+ printf("Press enter to exit test.\n");
+ std::getline(std::cin, line);
LOG("Network test finished.");
return 0;