UniSet  2.24.2
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 noexcept = 0;
33  virtual std::string toString() const noexcept = 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) noexcept = 0;
40  virtual ssize_t receive( void* r_buf, size_t sz ) = 0;
41  virtual void disconnect() = 0;
42  virtual int available() = 0;
43  };
44 
45  // Интерфейс для посылки данных в сеть
47  {
48  public:
49 
50  virtual ~UNetSendTransport() {}
51 
52  virtual bool isConnected() const = 0;
53  virtual std::string toString() const = 0;
54 
55  virtual bool createConnection( bool throwEx, timeout_t sendTimeout ) = 0;
56  virtual int getSocket() const = 0;
57 
58  // write
59  virtual bool isReadyForSend( timeout_t tout ) = 0;
60  virtual ssize_t send( const void* r_buf, size_t sz ) = 0;
61  };
62 } // end of uniset namespace
63 // -------------------------------------------------------------------------
64 #endif // UNetTransport_H_
65 // -------------------------------------------------------------------------
Definition: UNetTransport.h:27
Definition: UNetTransport.h:47
Definition: CommonEventLoop.h:15