diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-02-06 17:14:48 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-14 11:44:09 +0100 |
commit | 11a2e31306fdf68c101db6044b4a5347150e727c (patch) | |
tree | 201e16907aef2962965da21647766d94146434ee /Userland/Utilities | |
parent | 4ca0669d1e732b1697a7944a7899b2250bb81cf1 (diff) | |
download | serenity-11a2e31306fdf68c101db6044b4a5347150e727c.zip |
nc: Convert to Core::Stream::UDPSocket
Diffstat (limited to 'Userland/Utilities')
-rw-r--r-- | Userland/Utilities/nc.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Userland/Utilities/nc.cpp b/Userland/Utilities/nc.cpp index 5f622ea7bb..50a5cd1ddf 100644 --- a/Userland/Utilities/nc.cpp +++ b/Userland/Utilities/nc.cpp @@ -7,8 +7,8 @@ #include <AK/ByteBuffer.h> #include <LibCore/ArgsParser.h> #include <LibCore/EventLoop.h> +#include <LibCore/Stream.h> #include <LibCore/System.h> -#include <LibCore/UDPSocket.h> #include <LibMain/Main.h> #include <arpa/inet.h> #include <errno.h> @@ -54,14 +54,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } Core::EventLoop loop; - auto socket = TRY(Core::UDPSocket::try_create()); + auto socket = TRY(Core::Stream::UDPSocket::connect(target, port)); - socket->on_connected = [&]() { - if (verbose) - warnln("connected to {}:{}", target, port); - }; - - socket->connect(target, port); + if (verbose) + warnln("connected to {}:{}", target, port); Array<u8, 1024> buffer; for (;;) { @@ -69,7 +65,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto nread = TRY(Core::System::read(STDIN_FILENO, buffer_span)); buffer_span = buffer_span.trim(nread); - socket->send({ buffer_span.data(), static_cast<size_t>(nread) }); + TRY(socket->write({ buffer_span.data(), static_cast<size_t>(nread) })); } } |