Skip to content

Commit

Permalink
Vutils
Browse files Browse the repository at this point in the history
  • Loading branch information
vic4key committed Nov 1, 2023
1 parent 4feadda commit 4b4ecc3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/Vutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,10 @@ class Socket : public LastError
);
virtual ~Socket();

bool operator==(const Socket& right);
bool operator!=(const Socket& right);
const Socket& operator=(const Socket& right);

const SOCKET& vuapi handle() const;
const WSADATA& vuapi wsa_data() const;
const address_family_t vuapi af() const;
Expand Down
30 changes: 30 additions & 0 deletions src/details/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,36 @@ Socket::~Socket()
m_last_error_code = GetLastError();
}

bool Socket::operator==(const Socket& right)
{
return m_socket == m_socket;
}

bool Socket::operator!=(const Socket& right)
{
return !(*this == right);
}

const vu::Socket& Socket::operator=(const Socket& right)
{
if (this == &right)
{
return *this;
}

m_wsa = right.m_wsa;
m_type = right.m_type;
m_wsa_data = right.m_wsa_data;
m_af = right.m_af;
m_proto = right.m_proto;
m_sai = right.m_sai;
m_socket = right.m_socket;
m_options = right.m_options;
m_self = right.m_self;

return *this;
}

bool vuapi Socket::valid(const SOCKET& socket)
{
return !(socket == 0 || socket == INVALID_SOCKET);
Expand Down

0 comments on commit 4b4ecc3

Please sign in to comment.