TcpLib
Loading...
Searching...
No Matches
TcpReceiverTransmitter.h
Go to the documentation of this file.
1#ifndef INC_TCPRECEIVERTRANSMITTER_H
2#define INC_TCPRECEIVERTRANSMITTER_H
3//-----------------------------------------------------------------------------
43//-----------------------------------------------------------------------------
44#include "TcpTypes.h"
45
46#if defined (__PTHREADS)
47 #include "EuEndlessPThread.h"
48#else
49 #include "EuRepeatingThread.h"
50#endif
51
52#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
53 #include <winsock.h>
54#elif defined(__GNUC__)
55 /*
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <unistd.h>
59 */
60 #include <string.h>
61
62 #include <errno.h>
63 #include <sys/types.h>
64 #include <sys/socket.h>
65 #include <netinet/in.h>
66 #include <netdb.h>
67 #include <arpa/inet.h>
68 #define SOCKET uintptr_t
69 #define SOCKADDR_IN sockaddr_in
70 #define SOCKADDR sockaddr
71 #define HOSTENT hostent
72 #define INVALID_SOCKET (SOCKET)(~0)
73 #define SOCKET_ERROR (-1)
74#endif
75//-----------------------------------------------------------------------------
76#ifdef _MSC_VER
77 /* 'Bezeichner': Klasse 'Typ' benötigt eine DLL-Schnittstelle, die von... */
78 #pragma warning( disable : 4251 )
79 /* class 'TYP' ist keine DLL-Schnittstelle und wurde als Basisklasse... */
80 #pragma warning( disable : 4275 )
81#endif
82//-----------------------------------------------------------------------------
83namespace tcp
84{
85 //---------------------------------------------------------------------------
99 #if defined (__PTHREADS)
100 class __tcp_export_dll ReceiverTransmitter : public EuEndlessPThread
101 #else
103 #endif
104 {
105 protected:
106 //============== Attribute
107 //-----------------------------------------------------------------------
117 SOCKET m_Socket;
118 //-----------------------------------------------------------------------
119
120 //============== Konstruktor
121 //-----------------------------------------------------------------------
132 //-----------------------------------------------------------------------
133
134 public:
135 //============== Konstruktoren
136 //-----------------------------------------------------------------------
150 ReceiverTransmitter( SOCKET Socket );
151 //-----------------------------------------------------------------------
162 //-----------------------------------------------------------------------
163
164 private:
165 //============== Copy-Konstruktor
166 //-----------------------------------------------------------------------
177 //-----------------------------------------------------------------------
178
179 public:
180 //========== Methoden ========
181 //-----------------------------------------------------------------------
193 #if defined (__PTHREADS)
194 virtual int takeABreak();
195 #else
196 virtual void takeABreak() override;
197 #endif
198 //-----------------------------------------------------------------------
210 #if defined (__PTHREADS)
211 virtual int finishBreak();
212 #else
213 virtual void finishBreak() override;
214 #endif
215 //-----------------------------------------------------------------------
231 int getPeerName( std::string & rstrIPAdress, unsigned int & ruiPort ) const;
232 //-----------------------------------------------------------------------
242 SOCKET Socket() const;
243 //-----------------------------------------------------------------------
244
245 private:
246 //============== Operatoren
247 //-----------------------------------------------------------------------
258 //-----------------------------------------------------------------------
259 };
260 //---------------------------------------------------------------------------
261 #ifdef _MSC_VER
262 /* 'Bezeichner': Klasse 'Typ' benötigt eine DLL-Schnittstelle, die von... */
263 #pragma warning( default : 4251 )
264 /* class 'TYP' ist keine DLL-Schnittstelle und wurde als Basisklasse... */
265 #pragma warning( default : 4275 )
266 #endif
267 //---------------------------------------------------------------------------
268} // namespace tcp
269//-----------------------------------------------------------------------------
270#endif
Header for RepeatingThread
For each library, here 'TcpLib' there is a type file.
#define __tcp_export_dll
Definition TcpTypes.h:59
Base class for a thread that executes its work endlessly until aborted.
Definition EuRepeatingThread.h:93
Superclass for all Receiver and Transmitter, which communicate via a SOCKET.
Definition TcpReceiverTransmitter.h:104
virtual void takeABreak() override
SOCKET m_Socket
Definition TcpReceiverTransmitter.h:117
ReceiverTransmitter(const ReceiverTransmitter &)
virtual void finishBreak() override
int getPeerName(std::string &rstrIPAdress, unsigned int &ruiPort) const
ReceiverTransmitter(SOCKET Socket)
Definition TcpClient.h:55