Files
NXST/include/nxst/infra/net/socket.hpp
T
DragonSpirit 0f59912b5e
CI / Build NRO (push) Failing after 4s
CI / Format check (push) Successful in 41s
CI / Layering check (push) Successful in 1s
CI / Upload release asset (push) Has been skipped
finish refactor, add docs and CI
2026-04-27 02:53:15 +03:00

30 lines
498 B
C++

#pragma once
#include <unistd.h>
struct Socket {
int fd = -1;
Socket() = default;
explicit Socket(int fd) : fd(fd) {}
~Socket() {
if (fd >= 0)
close(fd);
}
Socket(const Socket&) = delete;
Socket& operator=(const Socket&) = delete;
Socket(Socket&& o) : fd(o.fd) {
o.fd = -1;
}
operator int() const {
return fd;
}
bool valid() const {
return fd >= 0;
}
void release() {
fd = -1;
}
};