mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:07:35 +00:00
LibCore: Change the signature of Socket::send() to use Span.
This commit is contained in:
parent
4709b700bd
commit
21de20825a
3 changed files with 6 additions and 5 deletions
|
@ -215,7 +215,7 @@ void IRCClient::process_line(ByteBuffer&& line)
|
||||||
|
|
||||||
void IRCClient::send(const String& text)
|
void IRCClient::send(const String& text)
|
||||||
{
|
{
|
||||||
if (!m_socket->send(ByteBuffer::wrap(text.characters(), text.length()))) {
|
if (!m_socket->send(text.bytes())) {
|
||||||
perror("send");
|
perror("send");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ ByteBuffer Socket::receive(int max_size)
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Socket::send(const ByteBuffer& data)
|
bool Socket::send(ReadonlyBytes data)
|
||||||
{
|
{
|
||||||
ssize_t nsent = ::send(fd(), data.data(), data.size(), 0);
|
ssize_t nsent = ::send(fd(), data.data(), data.size(), 0);
|
||||||
if (nsent < 0) {
|
if (nsent < 0) {
|
||||||
|
@ -182,8 +182,8 @@ void Socket::did_update_fd(int fd)
|
||||||
{
|
{
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (m_read_notifier) {
|
if (m_read_notifier) {
|
||||||
m_read_notifier->remove_from_parent();
|
m_read_notifier->remove_from_parent();
|
||||||
m_read_notifier = nullptr;
|
m_read_notifier = nullptr;
|
||||||
}
|
}
|
||||||
if (m_notifier) {
|
if (m_notifier) {
|
||||||
m_notifier->remove_from_parent();
|
m_notifier->remove_from_parent();
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
|
#include <AK/Span.h>
|
||||||
#include <LibCore/IODevice.h>
|
#include <LibCore/IODevice.h>
|
||||||
#include <LibCore/SocketAddress.h>
|
#include <LibCore/SocketAddress.h>
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ public:
|
||||||
bool connect(const SocketAddress&);
|
bool connect(const SocketAddress&);
|
||||||
|
|
||||||
ByteBuffer receive(int max_size);
|
ByteBuffer receive(int max_size);
|
||||||
bool send(const ByteBuffer&);
|
bool send(ReadonlyBytes);
|
||||||
|
|
||||||
bool is_connected() const { return m_connected; }
|
bool is_connected() const { return m_connected; }
|
||||||
void set_blocking(bool blocking);
|
void set_blocking(bool blocking);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue