GlobalObjects
Lade ...
Suche ...
Keine Treffer
TcpMain.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_TCPMAIN_H
2#define INC_TCPMAIN_H
3//-----------------------------------------------------------------------------
36//-----------------------------------------------------------------------------
37#include "TcpTypes.h"
38
39#if defined (__PTHREADS)
40 #include "EuEndlessPThread.h"
41 #include <semaphore.h>
42#else
43 #include "EuRepeatingThread.h"
44#endif
45
46#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
47 #include <winsock.h>
48#elif defined(__GNUC__)
49 /*
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <unistd.h>
53 */
54 #include <string.h>
55
56 #include <errno.h>
57 #include <sys/types.h>
58 #include <sys/socket.h>
59 #include <netinet/in.h>
60 #include <netdb.h>
61 #include <arpa/inet.h>
62 #define SOCKET uintptr_t
63 #define SOCKADDR_IN sockaddr_in
64 #define SOCKADDR sockaddr
65 #define HOSTENT hostent
66 #define INVALID_SOCKET (SOCKET)(~0)
67 #define SOCKET_ERROR (-1)
68#endif
69//-----------------------------------------------------------------------------
70namespace tcp
71{
72 //---------------------------------------------------------------------------
73 // Forwards
74 class Message;
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 //---------------------------------------------------------------------------
98 #if defined (__PTHREADS)
99 class __tcp_export_dll TcpMain : public EuEndlessPThread
100 #else
102 #endif
103 {
104 private:
105 //============== static-attributes
106 //-----------------------------------------------------------------------
120 static unsigned int m_uiTcpMainCounter;
121 //-----------------------------------------------------------------------
122
123 protected:
124 //============== attributes
125 //-----------------------------------------------------------------------
137 //-----------------------------------------------------------------------
149 unsigned int m_uiServerPort;
150 //-----------------------------------------------------------------------
162 unsigned int m_uiDataSize;
163 //-----------------------------------------------------------------------
174 //-----------------------------------------------------------------------
185 //-----------------------------------------------------------------------
196 //-----------------------------------------------------------------------
207 //-----------------------------------------------------------------------
208
209 //============== ctor
210 //-----------------------------------------------------------------------
221 //-----------------------------------------------------------------------
222
223 public:
224 //============== ctors
225 //-----------------------------------------------------------------------
257 TcpMain( unsigned int uiPort,
258 int iAdressFamily,
259 int iSocketType,
260 int iProtocol,
261 int iSecTimeOut );
262 //-----------------------------------------------------------------------
296 TcpMain( unsigned int uiPort,
297 int iAdressFamily,
298 int iSocketType,
299 int iProtocol,
300 unsigned int uiDataSize,
301 int iSecTimeOut );
302 //-----------------------------------------------------------------------
312 virtual ~TcpMain();
313 //-----------------------------------------------------------------------
314
315 private:
316 //============== copy-ctor
317 //-----------------------------------------------------------------------
327 TcpMain( const TcpMain & );
328 //-----------------------------------------------------------------------
329
330 public:
331 //============== methods
332 //-----------------------------------------------------------------------
342 unsigned int getPortNum() const;
343 //-----------------------------------------------------------------------
357 virtual void setDataSize( unsigned int uiDataSize );
358 //-----------------------------------------------------------------------
368 unsigned int getDataSize() const;
369 //-----------------------------------------------------------------------
379 SOCKET getMainSocket() const;
380 //-----------------------------------------------------------------------
406 virtual int send( Message * pTcpMessage ) = 0;
407 //-----------------------------------------------------------------------
419 void setTimeOutSec( int iSecTimeOut );
420 //-----------------------------------------------------------------------
433 //-----------------------------------------------------------------------
434
435 protected:
436 //============== methods
437 //-----------------------------------------------------------------------
449 void setWSACleanup() const;
450 //-----------------------------------------------------------------------
462 int startWinsock() const;
463 //-----------------------------------------------------------------------
464
465 private:
466 //============== operators
467 //-----------------------------------------------------------------------
477 TcpMain & operator= ( const TcpMain & );
478 //-----------------------------------------------------------------------
479 };
480 //---------------------------------------------------------------------------
481 #ifdef _MSC_VER
482 /* 'Bezeichner': Klasse 'Typ' benötigt eine DLL-Schnittstelle, die von... */
483 #pragma warning( default : 4251 )
484 /* class 'TYP' ist keine DLL-Schnittstelle und wurde als Basisklasse... */
485 #pragma warning( default : 4275 )
486 #endif
487 //---------------------------------------------------------------------------
488} // namespace tcp
489//-----------------------------------------------------------------------------
490#endif
Header für EuEndlessPThread
Header für RepeatingThread
Für jede Bibliothek, hier 'TcpLib' gibt es eine Typen-Datei.
#define __tcp_export_dll
Definition TcpTypes.h:53
Basisklasse für einen Thread der seine Arbeit endlos bis zum Abbruch ausführt.
Definition EuEndlessPThread.h:69
Basisklasse für einen Thread der seine Arbeit endlos bis zum Abbruch ausführt.
Definition EuRepeatingThread.h:78
Beinhaltet einen Datenstrom, welcher von den Tcp-Klassen versendet und empfangen werden kann.
Definition TcpMessage.h:161
Oberklasse für Client sowie Server, welche ihr KnowHow in den abgeleiteten Klassen 'lernt'.
Definition TcpMain.h:103
unsigned int getPortNum() const
void setWSACleanup() const
SOCKET m_MainSocket
Definition TcpMain.h:206
virtual void setDataSize(unsigned int uiDataSize)
TcpMain(const TcpMain &)
SOCKET getMainSocket() const
int startWinsock() const
virtual ~TcpMain()
int m_iSecTimeOut
Definition TcpMain.h:136
virtual int send(Message *pTcpMessage)=0
unsigned int m_uiServerPort
Definition TcpMain.h:149
int m_iSocketType
Definition TcpMain.h:184
TcpMain(unsigned int uiPort, int iAdressFamily, int iSocketType, int iProtocol, int iSecTimeOut)
unsigned int m_uiDataSize
Definition TcpMain.h:162
int m_iAdressFamily
Definition TcpMain.h:173
int TimeOutSec()
static unsigned int m_uiTcpMainCounter
Definition TcpMain.h:120
unsigned int getDataSize() const
TcpMain(unsigned int uiPort, int iAdressFamily, int iSocketType, int iProtocol, unsigned int uiDataSize, int iSecTimeOut)
void setTimeOutSec(int iSecTimeOut)
int m_iProtocol
Definition TcpMain.h:195
Definition TcpClient.h:48