GlobalObjects
Lade ...
Suche ...
Keine Treffer
TcpServer.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_TCPSERVER_H
2#define INC_TCPSERVER_H
3//-----------------------------------------------------------------------------
43//-----------------------------------------------------------------------------
44#include "TcpTypes.h"
45#include "TcpMain.h"
46#include "TcpMessage.h"
47#include <queue>
48#include <map>
49//-----------------------------------------------------------------------------
50namespace tcp
51{
52 //---------------------------------------------------------------------------
53 #ifdef _MSC_VER
54 /* 'Bezeichner': Klasse 'Typ' benötigt eine DLL-Schnittstelle, die von... */
55 #pragma warning( disable : 4251 )
56 /* class 'TYP' ist keine DLL-Schnittstelle und wurde als Basisklasse... */
57 #pragma warning( disable : 4275 )
58 #endif
59 //---------------------------------------------------------------------------
60 //Forwards
61 class Transmitter;
62 class ServerReceiver;
63 class ServerAcceptReceiver;
64 //---------------------------------------------------------------------------
268 {
269 public:
270 //-----------------------------------------------------------------------
271 // >>>>>>>>>>>>>>>>>> ServerReceiverTransmitter >>>>>>>>>>>>>>>>>>>>>>>>>
272 //-----------------------------------------------------------------------
286 {
287 private:
288 //============== Attribute
289 //---------------------------------------------------------------------
300 //---------------------------------------------------------------------
311 //---------------------------------------------------------------------
312
313 protected:
314 //============== Konstruktoren
315 //---------------------------------------------------------------------
326 //---------------------------------------------------------------------
327
328 public:
329 //============== Konstruktoren
330 //---------------------------------------------------------------------
354 //---------------------------------------------------------------------
367 //---------------------------------------------------------------------
368
369 private:
370 //============== Copy-Konstruktor
371 //---------------------------------------------------------------------
382 //---------------------------------------------------------------------
383
384 public:
385 //============== Methoden
386 //---------------------------------------------------------------------
414 int send( char * pszRawMsg,
415 unsigned int uiRawMsgSize,
416 unsigned int uiMessageID = 0,
417 int iActionCode = 0,
418 const std::string & rstrInfo = "" );
419 //---------------------------------------------------------------------
441 int send( Message * pTcpMessage );
442 //---------------------------------------------------------------------
452 void setValid( bool bValid );
453 //---------------------------------------------------------------------
469 int getPeerName( std::string & rstrIPAdress, unsigned int & ruiPort ) const;
470 //---------------------------------------------------------------------
482 SOCKET Socket() const;
483 //---------------------------------------------------------------------
484 private:
485 //============== Operatoren
486 //---------------------------------------------------------------------
497 //---------------------------------------------------------------------
498 };
499 //-----------------------------------------------------------------------
500 // <<<<<<<<<<<<<<<<< ServerReceiverTransmitter <<<<<<<<<<<<<<<<<<<<<<<<<<
501 //-----------------------------------------------------------------------
502
503 private:
504 //============== Attribute
505 //-----------------------------------------------------------------------
517 unsigned long m_ulMaxClients;
518 //-----------------------------------------------------------------------
528 std::queue<AbstractMessage *> m_MsgQueue;
529 //-----------------------------------------------------------------------
530
531 protected:
532 //-----------------------------------------------------------------------
543 //-----------------------------------------------------------------------
553 std::map< SOCKET, ServerReceiverTransmitter *, std::less< SOCKET > > m_ClientMap;
554 //-----------------------------------------------------------------------
555
556 //============== Konstruktor
557 //-----------------------------------------------------------------------
568 //-----------------------------------------------------------------------
578 Server( unsigned int, int, int, int, int );
579 //-----------------------------------------------------------------------
589 Server( unsigned int, int, int, int, unsigned int, int );
590 //-----------------------------------------------------------------------
591
592 public:
593 //============== Konstruktoren
594 //-----------------------------------------------------------------------
625 Server( unsigned int uiPort,
626 int iAdressFamily,
627 int iSocketType,
628 int iProtocol,
629 unsigned int uiDataSize,
630 unsigned long ulMaxClients,
631 int iSecTimeOut );
632 //-----------------------------------------------------------------------
642 virtual ~Server();
643 //-----------------------------------------------------------------------
644
645 private:
646 //============== Copy-Konstruktor
647 //-----------------------------------------------------------------------
657 Server( const Server & rT );
658 //-----------------------------------------------------------------------
659
660 //============== Methoden
661 //-----------------------------------------------------------------------
675 void init();
676 //-----------------------------------------------------------------------
677
678 protected:
679 //============== Methoden
680 //-----------------------------------------------------------------------
692 virtual void work() override;
693 //-----------------------------------------------------------------------
694 #if defined (__PTHREADS)
710 virtual void cleanUp();
711 //-----------------------------------------------------------------------
712 #else
713
714 public:
715 //============== Methoden
716 //-------------------------------------------------------------------------
732 virtual void cancel() override;
733 //-----------------------------------------------------------------------
734 #endif
735
736 protected:
737 //============== Methoden
738 //-----------------------------------------------------------------------
754 virtual void insertNewClient( Server::ServerReceiverTransmitter * pNewServerReceiverTransmitter );
755 //-----------------------------------------------------------------------
777 //-----------------------------------------------------------------------
793 int virtual removeClient( SOCKET Socket );
794 //-----------------------------------------------------------------------
817 SOCKET Socket,
818 unsigned int iDataSize ) const;
819 //-----------------------------------------------------------------------
832 void setClientMapReceiverValid( bool bValid );
833 //-----------------------------------------------------------------------
845 //-----------------------------------------------------------------------
857 unsigned long getMaxClients() const;
858 //-----------------------------------------------------------------------
874 virtual void processClientMessage (AbstractMessage * pTcpMessage);
875 //-----------------------------------------------------------------------
907 virtual int send( SOCKET ClientSocket,
908 char * pszRawMsg,
909 unsigned int uiRawMsgSize,
910 unsigned int uiMessageID = 0,
911 int iActionCode = 0,
912 const std::string & rstrInfo = "" );
913 //-----------------------------------------------------------------------
938 virtual int send( Message * pTcpMessage ) override;
939 //-----------------------------------------------------------------------
940
941 public:
942 //============== Methoden
943 //-----------------------------------------------------------------------
960 //-----------------------------------------------------------------------
961
962 private:
963 //============== Operatoren
964 //-----------------------------------------------------------------------
974 Server & operator= ( const Server & );
975 //-----------------------------------------------------------------------
976 };
977 //---------------------------------------------------------------------------
978 #ifdef _MSC_VER
979 /* 'Bezeichner': Klasse 'Typ' benötigt eine DLL-Schnittstelle, die von... */
980 #pragma warning( default : 4251 )
981 /* class 'TYP' ist keine DLL-Schnittstelle und wurde als Basisklasse... */
982 #pragma warning( default : 4275 )
983 #endif
984 //---------------------------------------------------------------------------
985} // namespace tcp
986//-----------------------------------------------------------------------------
987#endif
Header für TcpMain
Header für AbstractMessage, Message, ServerAcceptMessage und ServerMessage.
Für jede Bibliothek, hier 'TcpLib' gibt es eine Typen-Datei.
#define __tcp_export_dll
Definition TcpTypes.h:59
Basisklasse für Nachrichten, welche von den Tcp-Klassen verschickt, empfangen und bearbeitet werden k...
Definition TcpMessage.h:97
Beinhaltet einen Datenstrom, welcher von den Tcp-Klassen versendet und empfangen werden kann.
Definition TcpMessage.h:168
Tuple von Socket-Receiver und -Transmitter für den Server.
Definition TcpServer.h:286
int send(Message *pTcpMessage)
Transmitter * m_pTransmitter
Definition TcpServer.h:310
ServerReceiverTransmitter(const ServerReceiverTransmitter &rT)
int send(char *pszRawMsg, unsigned int uiRawMsgSize, unsigned int uiMessageID=0, int iActionCode=0, const std::string &rstrInfo="")
int getPeerName(std::string &rstrIPAdress, unsigned int &ruiPort) const
ServerReceiverTransmitter(Transmitter *pTransmitter, ServerReceiver *pReceiver)
ServerReceiver * m_pReceiver
Definition TcpServer.h:299
Accept-Receiver nimmt neue Clients an und meldet diese bei seinem Eltern-Objekt an (i....
Definition TcpServerAcceptReceiver.h:83
Eine einfache TCP-Serverklasse, welche ihr KnowHow in den abgeleiteten Klassen lernen soll.
Definition TcpServer.h:268
virtual void insertNewClient(Server::ServerReceiverTransmitter *pNewServerReceiverTransmitter)
virtual int send(SOCKET ClientSocket, char *pszRawMsg, unsigned int uiRawMsgSize, unsigned int uiMessageID=0, int iActionCode=0, const std::string &rstrInfo="")
Server(unsigned int, int, int, int, unsigned int, int)
virtual Server::ServerReceiverTransmitter * generateNewServerReceiverTransmitter(Server *pParent, SOCKET Socket, unsigned int iDataSize) const
Server(const Server &rT)
void clearClientMap()
virtual int removeClient(SOCKET Socket)
std::queue< AbstractMessage * > m_MsgQueue
Definition TcpServer.h:528
virtual ~Server()
virtual void cancel() override
unsigned long m_ulMaxClients
Definition TcpServer.h:517
void setClientMapReceiverValid(bool bValid)
int acceptClientMessage(AbstractMessage *pTcpMessage)
virtual int send(Message *pTcpMessage) override
Server(unsigned int uiPort, int iAdressFamily, int iSocketType, int iProtocol, unsigned int uiDataSize, unsigned long ulMaxClients, int iSecTimeOut)
std::map< SOCKET, ServerReceiverTransmitter *, std::less< SOCKET > > m_ClientMap
Definition TcpServer.h:553
Server(unsigned int, int, int, int, int)
Server::ServerReceiverTransmitter * getClient(SOCKET Socket)
virtual void work() override
ServerAcceptReceiver * m_pAcceptReceiver
Definition TcpServer.h:542
unsigned long getMaxClients() const
virtual void processClientMessage(AbstractMessage *pTcpMessage)
Klasse, welche über ein SOCKET mit einem Client kommunizieret und ihr Empfangsergebnis vom Typ Server...
Definition TcpServerReceiver.h:81
Oberklasse für Client sowie Server, welche ihr KnowHow in den abgeleiteten Klassen 'lernt'.
Definition TcpMain.h:110
Eine Klasse, welche über ein SOCKET mit einem Client oder Server kommunizieret und Senddaten vom Typ ...
Definition TcpTransmitter.h:75
Definition TcpClient.h:55