ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Connection.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <memory>
11 #include <string>
12 
13 #include "io/rpc/ConnectionBase.h"
14 #include "io/rpc/ZMQContext.h"
15 
16 namespace cloudViewer {
17 namespace io {
18 namespace rpc {
19 
22 class Connection : public ConnectionBase {
23 public:
25  Connection();
26 
35  Connection(const std::string& address, int connect_timeout, int timeout);
36  ~Connection();
37 
39  std::shared_ptr<zmq::message_t> Send(zmq::message_t& send_msg);
40 
42  std::shared_ptr<zmq::message_t> Send(const void* data, size_t size);
43 
44  static std::string DefaultAddress();
45 
46 private:
47  std::shared_ptr<zmq::context_t> context_;
48  std::unique_ptr<zmq::socket_t> socket_;
49  const std::string address_;
50  const int connect_timeout_;
51  const int timeout_;
52 };
53 } // namespace rpc
54 } // namespace io
55 } // namespace cloudViewer
int size
Base class for all connections.
std::shared_ptr< zmq::message_t > Send(zmq::message_t &send_msg)
Function for sending data wrapped in a zmq message object.
Definition: Connection.cpp:53
static std::string DefaultAddress()
Definition: Connection.cpp:80
Connection()
Creates a connection with the default parameters.
Definition: Connection.cpp:32
Generic file read and write utility for python interface.