YARP
Yet Another Robot Platform
TcpAcceptor.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2010 Anne van Rossum <anne@almende.com>
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_OS_IMPL_POSIX_TCPACCEPTOR_H
8 #define YARP_OS_IMPL_POSIX_TCPACCEPTOR_H
9 
10 
11 #include <yarp/os/TwoWayStream.h>
12 
14 
15 // General files
16 
17 namespace yarp {
18 namespace os {
19 namespace impl {
20 namespace posix {
21 
22 
23 /* **************************************************************************************
24  * Interface of TcpAcceptor
25  * **************************************************************************************/
26 
28 {
29 public:
30  TcpAcceptor() = default;
31 
32  virtual ~TcpAcceptor() = default;
33 
34  int open(const yarp::os::Contact& address);
35 
36  int connect(const yarp::os::Contact& address);
37 
38  int close();
39 
40  int accept(TcpStream &new_stream);
41 
43  {
44  return port_number;
45  }
46 
47 protected:
48  int shared_open(const yarp::os::Contact& address);
49 
50  int get_handle()
51  {
52  return ad;
53  }
54 
55  void set_handle(int h)
56  {
57  ad = h;
58  }
59 
60 private:
61  // acceptor descriptor
62  int ad {-1};
63  int port_number {-1};
64 };
65 
66 } // namespace posix
67 } // namespace impl
68 } // namespace os
69 } // namespace yarp
70 
71 
72 #endif // YARP_OS_IMPL_POSIX_TCPACCEPTOR_H
Represents how to reach a part of a YARP network.
Definition: Contact.h:36
int connect(const yarp::os::Contact &address)
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_impl_API
Definition: api.h:46