summaryrefslogtreecommitdiff
path: root/Services/TelnetServer
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-09-20 12:41:01 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-21 09:37:49 +0200
commit26f4b5e6ba348aebe8af3e555defd897a5084ad3 (patch)
tree1092aed3a759c43398f69b6d799b11d019a3d460 /Services/TelnetServer
parent8f06e4aaa45694868a2ef9e6b649fe7aa6a8e9ee (diff)
downloadserenity-26f4b5e6ba348aebe8af3e555defd897a5084ad3.zip
TelnetServer: Use OutputMemoryStream instead of BufferStream.
I could not test these changes because I could not get my telnet client (on Linux) to connect to the telnet server running in Serenity. I tried the follwing: # Serenity su TelnetServer # Linux telnet localhost 8823 The server then immediatelly closes the connection: Connection closed by foreign host. In the debug logs the following message appears: [NetworkTask(5:5)]: handle_tcp: unexpected flags in FinWait2 state [NetworkTask(5:5)]: handle_tcp: unexpected flags in Closed state [NetworkTask(5:5)]: handle_tcp: unexpected flags in Closed state This seems to be an unrelated bug in the TCP implementation.
Diffstat (limited to 'Services/TelnetServer')
-rw-r--r--Services/TelnetServer/Client.cpp8
-rw-r--r--Services/TelnetServer/main.cpp1
2 files changed, 5 insertions, 4 deletions
diff --git a/Services/TelnetServer/Client.cpp b/Services/TelnetServer/Client.cpp
index e983025df6..dba7c8a052 100644
--- a/Services/TelnetServer/Client.cpp
+++ b/Services/TelnetServer/Client.cpp
@@ -25,8 +25,8 @@
*/
#include "Client.h"
-#include <AK/BufferStream.h>
#include <AK/ByteBuffer.h>
+#include <AK/MemoryStream.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
@@ -171,10 +171,12 @@ void Client::send_command(Command command)
void Client::send_commands(Vector<Command> commands)
{
auto buffer = ByteBuffer::create_uninitialized(commands.size() * 3);
- BufferStream stream(buffer);
+ OutputMemoryStream stream { buffer };
+
for (auto& command : commands)
stream << (u8)IAC << command.command << command.subcommand;
- stream.snip();
+
+ ASSERT(stream.is_end());
m_socket->write(buffer.data(), buffer.size());
}
diff --git a/Services/TelnetServer/main.cpp b/Services/TelnetServer/main.cpp
index 6acb900b61..3fd26aff42 100644
--- a/Services/TelnetServer/main.cpp
+++ b/Services/TelnetServer/main.cpp
@@ -25,7 +25,6 @@
*/
#include "Client.h"
-#include <AK/BufferStream.h>
#include <AK/ByteBuffer.h>
#include <AK/HashMap.h>
#include <AK/IPv4Address.h>