mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:17:35 +00:00
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.
This commit is contained in:
parent
8f06e4aaa4
commit
26f4b5e6ba
2 changed files with 5 additions and 4 deletions
|
@ -25,8 +25,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include <AK/BufferStream.h>
|
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
|
#include <AK/MemoryStream.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
|
@ -171,10 +171,12 @@ void Client::send_command(Command command)
|
||||||
void Client::send_commands(Vector<Command> commands)
|
void Client::send_commands(Vector<Command> commands)
|
||||||
{
|
{
|
||||||
auto buffer = ByteBuffer::create_uninitialized(commands.size() * 3);
|
auto buffer = ByteBuffer::create_uninitialized(commands.size() * 3);
|
||||||
BufferStream stream(buffer);
|
OutputMemoryStream stream { buffer };
|
||||||
|
|
||||||
for (auto& command : commands)
|
for (auto& command : commands)
|
||||||
stream << (u8)IAC << command.command << command.subcommand;
|
stream << (u8)IAC << command.command << command.subcommand;
|
||||||
stream.snip();
|
|
||||||
|
ASSERT(stream.is_end());
|
||||||
m_socket->write(buffer.data(), buffer.size());
|
m_socket->write(buffer.data(), buffer.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include <AK/BufferStream.h>
|
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
#include <AK/HashMap.h>
|
#include <AK/HashMap.h>
|
||||||
#include <AK/IPv4Address.h>
|
#include <AK/IPv4Address.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue