Skip to content

Commit

Permalink
update Socket.send, recv
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Nov 11, 2024
1 parent dc84fe1 commit 40ba770
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/network/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ static inline int connectsocket(
}

static inline int recvsocket(
int descriptor, void* buf, size_t len, int flags
int descriptor, char* buf, size_t len, int flags
) noexcept {
return recv(descriptor, buf, len, flags);
}

static inline int sendsocket(
int descriptor, const void* buf, size_t len, int flags
int descriptor, const char* buf, size_t len, int flags
) noexcept {
return send(descriptor, buf, len, flags);
}
Expand Down Expand Up @@ -146,7 +146,7 @@ class SocketImpl : public Socket {
freeaddrinfo(addr);
}

int recv(void* buffer, size_t length, bool blocking) override {
int recv(char* buffer, size_t length, bool blocking) override {
int len = recvsocket(descriptor, buffer, length, blocking ? MSG_WAITALL : MSG_DONTWAIT);
if (len == 0) {
int err = errno;
Expand All @@ -162,7 +162,7 @@ class SocketImpl : public Socket {
return len;
}

int send(const void* buffer, size_t length) override {
int send(const char* buffer, size_t length) override {
int len = sendsocket(descriptor, buffer, length, 0);
if (len == -1) {
int err = errno;
Expand Down
4 changes: 2 additions & 2 deletions src/network/Network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace network {

class Socket {
public:
virtual int recv(void* buffer, size_t length, bool blocking) = 0;
virtual int send(const void* buffer, size_t length) = 0;
virtual int recv(char* buffer, size_t length, bool blocking) = 0;
virtual int send(const char* buffer, size_t length) = 0;
virtual void close() = 0;
virtual bool isOpen() const = 0;

Expand Down

0 comments on commit 40ba770

Please sign in to comment.