2024-11-12 08:52:55 +00:00
|
|
|
#include "rpc_server.hpp"
|
2024-11-20 10:07:36 +00:00
|
|
|
#include "socket.hpp"
|
2024-11-18 11:35:38 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2024-11-20 10:07:36 +00:00
|
|
|
auto slige_rpc::RpcServer::bind(
|
|
|
|
uint16_t port) -> std::variant<slige_rpc::RpcServer, slige_socket::Ewwow>
|
2024-11-18 11:35:38 +00:00
|
|
|
{
|
2024-11-20 10:07:36 +00: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 11:35:38 +00:00
|
|
|
}
|
2024-11-20 10:07:36 +00:00
|
|
|
return RpcServer(std::get<slige_socket::ServerSocket>(socket_result));
|
2024-11-18 11:35:38 +00:00
|
|
|
}
|