UniSet  2.12.1
UNetTransport.h
1 /*
2  * Copyright (c) 2021 Pavel Vainerman.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, version 2.1.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Lesser Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 // -------------------------------------------------------------------------
17 #ifndef UNetTransport_H_
18 #define UNetTransport_H_
19 // -------------------------------------------------------------------------
20 #include <string>
21 #include "PassiveTimer.h" // for typedef timeout_t
22 // -------------------------------------------------------------------------
23 namespace uniset
24 {
25  // Интерфейс для получения данных по сети
27  {
28  public:
29 
30  virtual ~UNetReceiveTransport() {}
31 
32  virtual bool isConnected() const = 0;
33  virtual std::string toString() const = 0;
34  virtual std::string ID() const noexcept = 0;
35 
36  virtual bool createConnection( bool throwEx, timeout_t recvTimeout, bool noblock ) = 0;
37  virtual int getSocket() const = 0;
38 
39  virtual bool isReadyForReceive(timeout_t tout) = 0;
40  virtual ssize_t receive( void* r_buf, size_t sz ) = 0;
41  virtual void disconnect() = 0;
42  };
43 
44  // Интерфейс для посылки данных в сеть
46  {
47  public:
48 
49  virtual ~UNetSendTransport() {}
50 
51  virtual bool isConnected() const = 0;
52  virtual std::string toString() const = 0;
53 
54  virtual bool createConnection( bool throwEx, timeout_t sendTimeout ) = 0;
55  virtual int getSocket() const = 0;
56 
57  // write
58  virtual bool isReadyForSend( timeout_t tout ) = 0;
59  virtual ssize_t send( const void* r_buf, size_t sz ) = 0;
60  };
61 } // end of uniset namespace
62 // -------------------------------------------------------------------------
63 #endif // UNetTransport_H_
64 // -------------------------------------------------------------------------
Definition: CommonEventLoop.h:14
Definition: UNetTransport.h:45
Definition: UNetTransport.h:26