tcp_connection.h
1 
2 #pragma once
3 
4 #include "network_condition_variable.h"
5 
6 #include <memory>
7 #include <vector>
8 #include <mutex>
9 
10 namespace uicore
11 {
12  class SocketName;
13 
15  class TCPConnection : public NetworkEvent
16  {
17  public:
19  static std::shared_ptr<TCPConnection> connect(const SocketName &endpoint);
20 
22  virtual SocketName local_name() = 0;
23 
25  virtual SocketName remote_name() = 0;
26 
28  virtual void close() = 0;
29 
32  virtual int write(const void *data, int size) = 0;
33 
36  virtual int read(void *data, int size) = 0;
37 
38  // To do: QOSAddSocketToFlow
39  };
40 
41  typedef std::shared_ptr<TCPConnection> TCPConnectionPtr;
42 }
virtual SocketName local_name()=0
Returns the socket name of the local end point.
static std::shared_ptr< TCPConnection > connect(const SocketName &endpoint)
Blocking connect to end point.
virtual int read(void *data, int size)=0
Read data from TCP socket.
Socket name; container class for an IP address and port.
Definition: socket_name.h:39
Base class for all classes that generate network events.
Definition: network_condition_variable.h:14
virtual SocketName remote_name()=0
Returns the socket name of the peer end point.
virtual int write(const void *data, int size)=0
Write data to TCP socket.
virtual void close()=0
Close connection.
TCP/IP socket connection.
Definition: tcp_connection.h:15
Definition: Application/application.h:35
std::shared_ptr< TCPConnection > TCPConnectionPtr
Definition: tcp_connection.h:41