diff options
Diffstat (limited to 'src/core/network/sockets.h')
| -rw-r--r-- | src/core/network/sockets.h | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/src/core/network/sockets.h b/src/core/network/sockets.h deleted file mode 100644 index f889159f5..000000000 --- a/src/core/network/sockets.h +++ /dev/null | |||
| @@ -1,94 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <memory> | ||
| 7 | #include <utility> | ||
| 8 | |||
| 9 | #if defined(_WIN32) | ||
| 10 | #elif !YUZU_UNIX | ||
| 11 | #error "Platform not implemented" | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #include "common/common_types.h" | ||
| 15 | #include "core/network/network.h" | ||
| 16 | |||
| 17 | // TODO: C++20 Replace std::vector usages with std::span | ||
| 18 | |||
| 19 | namespace Network { | ||
| 20 | |||
| 21 | class Socket { | ||
| 22 | public: | ||
| 23 | struct AcceptResult { | ||
| 24 | std::unique_ptr<Socket> socket; | ||
| 25 | SockAddrIn sockaddr_in; | ||
| 26 | }; | ||
| 27 | |||
| 28 | explicit Socket() = default; | ||
| 29 | ~Socket(); | ||
| 30 | |||
| 31 | Socket(const Socket&) = delete; | ||
| 32 | Socket& operator=(const Socket&) = delete; | ||
| 33 | |||
| 34 | Socket(Socket&& rhs) noexcept; | ||
| 35 | |||
| 36 | // Avoid closing sockets implicitly | ||
| 37 | Socket& operator=(Socket&&) noexcept = delete; | ||
| 38 | |||
| 39 | Errno Initialize(Domain domain, Type type, Protocol protocol); | ||
| 40 | |||
| 41 | Errno Close(); | ||
| 42 | |||
| 43 | std::pair<AcceptResult, Errno> Accept(); | ||
| 44 | |||
| 45 | Errno Connect(SockAddrIn addr_in); | ||
| 46 | |||
| 47 | std::pair<SockAddrIn, Errno> GetPeerName(); | ||
| 48 | |||
| 49 | std::pair<SockAddrIn, Errno> GetSockName(); | ||
| 50 | |||
| 51 | Errno Bind(SockAddrIn addr); | ||
| 52 | |||
| 53 | Errno Listen(s32 backlog); | ||
| 54 | |||
| 55 | Errno Shutdown(ShutdownHow how); | ||
| 56 | |||
| 57 | std::pair<s32, Errno> Recv(int flags, std::vector<u8>& message); | ||
| 58 | |||
| 59 | std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr); | ||
| 60 | |||
| 61 | std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags); | ||
| 62 | |||
| 63 | std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message, const SockAddrIn* addr); | ||
| 64 | |||
| 65 | Errno SetLinger(bool enable, u32 linger); | ||
| 66 | |||
| 67 | Errno SetReuseAddr(bool enable); | ||
| 68 | |||
| 69 | Errno SetKeepAlive(bool enable); | ||
| 70 | |||
| 71 | Errno SetBroadcast(bool enable); | ||
| 72 | |||
| 73 | Errno SetSndBuf(u32 value); | ||
| 74 | |||
| 75 | Errno SetRcvBuf(u32 value); | ||
| 76 | |||
| 77 | Errno SetSndTimeo(u32 value); | ||
| 78 | |||
| 79 | Errno SetRcvTimeo(u32 value); | ||
| 80 | |||
| 81 | Errno SetNonBlock(bool enable); | ||
| 82 | |||
| 83 | bool IsOpened() const; | ||
| 84 | |||
| 85 | #if defined(_WIN32) | ||
| 86 | SOCKET fd = INVALID_SOCKET; | ||
| 87 | #elif YUZU_UNIX | ||
| 88 | int fd = -1; | ||
| 89 | #endif | ||
| 90 | }; | ||
| 91 | |||
| 92 | std::pair<s32, Errno> Poll(std::vector<PollFD>& poll_fds, s32 timeout); | ||
| 93 | |||
| 94 | } // namespace Network | ||