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