slige/runtime/rpc_server.cpp

16 lines
544 B
C++
Raw Normal View History

2024-11-12 09:52:55 +01:00
#include "rpc_server.hpp"
2024-11-20 11:07:36 +01:00
#include "socket.hpp"
2024-11-18 12:35:38 +01:00
#include <sys/socket.h>
#include <unistd.h>
2024-11-20 11:07:36 +01:00
auto slige_rpc::RpcServer::bind(
uint16_t port) -> std::variant<slige_rpc::RpcServer, slige_socket::Ewwow>
2024-11-18 12:35:38 +01:00
{
2024-11-20 11:07:36 +01:00
std::variant<slige_socket::ServerSocket, slige_socket::Ewwow> socket_result
= slige_socket::Socket::bind(port);
if (std::holds_alternative<slige_socket::Ewwow>(socket_result)) {
return std::get<slige_socket::Ewwow>(socket_result);
2024-11-18 12:35:38 +01:00
}
2024-11-20 11:07:36 +01:00
return RpcServer(std::get<slige_socket::ServerSocket>(socket_result));
2024-11-18 12:35:38 +01:00
}