| Line | |
|---|
| 1 | #ifndef COSY_MTcpIpIO
|
|---|
| 2 | #define COSY_MTcpIpIO
|
|---|
| 3 |
|
|---|
| 4 | #ifndef MARS_MThread
|
|---|
| 5 | #include "MThread.h"
|
|---|
| 6 | #endif
|
|---|
| 7 | #ifndef MARS_MTime
|
|---|
| 8 | #include "MTime.h"
|
|---|
| 9 | #endif
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | class TString;
|
|---|
| 13 | class TSocket;
|
|---|
| 14 | class TServerSocket;
|
|---|
| 15 |
|
|---|
| 16 | // A generalized class for receiving over tcp/ip
|
|---|
| 17 | class MTcpIpI : public MThread
|
|---|
| 18 | {
|
|---|
| 19 | private:
|
|---|
| 20 | Int_t fPortRx;
|
|---|
| 21 |
|
|---|
| 22 | Int_t Thread();
|
|---|
| 23 |
|
|---|
| 24 | virtual void ReadSocket(TSocket &rx) = 0;
|
|---|
| 25 |
|
|---|
| 26 | public:
|
|---|
| 27 | MTcpIpI(Int_t rx) : MThread(Form("MTcpIpI::%d", rx)), fPortRx(rx) { /*RunThread();*/ }
|
|---|
| 28 | ~MTcpIpI() { CancelThread(); }
|
|---|
| 29 | };
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | // A generalized class for sending over tcp/ip
|
|---|
| 33 | class MTcpIpO
|
|---|
| 34 | {
|
|---|
| 35 | private:
|
|---|
| 36 | TSocket *fTxSocket;
|
|---|
| 37 |
|
|---|
| 38 | public:
|
|---|
| 39 | MTcpIpO(const char *addr, Int_t tx);
|
|---|
| 40 | ~MTcpIpO();
|
|---|
| 41 |
|
|---|
| 42 | static bool SendFrame(TSocket &tx, const char *msg, int len);
|
|---|
| 43 | static bool SendFrame(const char *addr, int port, const char *msg, int len);
|
|---|
| 44 |
|
|---|
| 45 | bool Send(const char *msg, int len);
|
|---|
| 46 | };
|
|---|
| 47 |
|
|---|
| 48 | // This class es espcially meant to receive and send ascii messages
|
|---|
| 49 | class MTcpIpIO : public MTcpIpI, public MTcpIpO
|
|---|
| 50 | {
|
|---|
| 51 | private:
|
|---|
| 52 | void ReadSocket(TSocket &rx);
|
|---|
| 53 |
|
|---|
| 54 | public:
|
|---|
| 55 | MTcpIpIO(const char *addr, Int_t tx, Int_t rx);
|
|---|
| 56 | ~MTcpIpIO();
|
|---|
| 57 |
|
|---|
| 58 | virtual bool InterpreteStr(TString str);
|
|---|
| 59 | };
|
|---|
| 60 |
|
|---|
| 61 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.