Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
server.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 NVIDIA Corporation
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __SERVER_H__
19#define __SERVER_H__
20
21#include <string>
22#include <unordered_map>
23#include <vector>
24
25#include <sys/socket.h>
26
27#include "logger.h"
28#include "types.h"
29
30namespace mesh {
31 // @class Server
32 // @brief Server in client-server architecture.
33 class Server {
34 mesh::NodeIdent self_;
35 int grp_sz_; // size of the group
36 int ai_family_{AF_INET};
37
38 std::vector<int> socks_;
39 // Map of receiving sockets
40 std::unordered_map<std::string, int> recv_socks_;
41 std::shared_ptr<p2p::Logger::p2p_log> p2p_log_{nullptr};
42
43 void handle_client_(int client_sock);
44 void set_sock_addr_(const char *address_str, struct sockaddr_in *saddr);
45 int listen_();
46
47 public:
48 Server(mesh::NodeIdent, int group_sz);
49
56 int start();
57
66 int recv_buf(const std::string &src, void *buf, size_t len);
67
72 int shutdown();
73 };
74} // namespace mesh
75
76#endif
Definition server.h:33
int shutdown()
close each connection connected to client on all the workers.
int recv_buf(const std::string &src, void *buf, size_t len)
Receives data from the source.
Server(mesh::NodeIdent, int group_sz)
int start()
Start server on well know port. Accepts connection from all the clients. Store socket ids in recv_soc...
Definition client.h:29
Definition types.h:27
NodeID src
Definition ucp_internal.h:1