Faspstream Manager C/C++ API  3.6.1
A C and C++ language interface to basic streaming over the fasp protocol
ChannelHandler.h
Go to the documentation of this file.
1 /*
2  * Aspera, Inc.
3  *
4  * Internal class.
5  *
6  * Used in the TCP out-of-band / tunneling feature. This class's run
7  * method is executed by a background thread.
8  *
9  * Tunnels communication to and from remote faspstream through
10  * local socket connected to faspstream process.
11  */
12 #include <Poco/Runnable.h>
13 #include <Poco/Net/StreamSocket.h>
14 #include "FaspConnectionChannel.h"
15 
16 class ChannelHandler : public Poco::Runnable
17 {
18 public:
25  ChannelHandler(Poco::Net::StreamSocket& socket,
26  FaspConnectionChannel& channel) :
27  _socket(socket),
28  _channel(&channel),
29  _pBuffer(new char[BUFFER_SIZE]),
30  _shouldStop(0)
31  {
32  }
33  ~ChannelHandler() { delete [] this->_pBuffer; }
34 
40  virtual void run();
46  virtual void stop();
47 
48 private:
53  enum {
54  BUFFER_SIZE = 1024
55  };
56 
57  Poco::Net::StreamSocket _socket;
58  FaspConnectionChannel* _channel;
59  char* _pBuffer;
60  int _shouldStop;
61 
68  int try_send_remote(Poco::Net::StreamSocket ss);
69  int try_read_remote(Poco::Net::StreamSocket ss);
70  int run_once(Poco::Net::StreamSocket ss);
71 
72 };
73 
Definition: ChannelHandler.h:16
virtual void stop()
ChannelHandler(Poco::Net::StreamSocket &socket, FaspConnectionChannel &channel)
Definition: ChannelHandler.h:25
Definition: FaspConnectionChannel.h:33
~ChannelHandler()
Definition: ChannelHandler.h:33
virtual void run()