GlobalObjects
Lade ...
Suche ...
Keine Treffer
TcpClient.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_TCPCLIENT_H
2#define INC_TCPCLIENT_H
3//-----------------------------------------------------------------------------
43//-----------------------------------------------------------------------------
44#include "TcpTypes.h"
45#include "TcpMain.h"
47#include <string>
48#include <queue>
49#include "TcpMessage.h"
50#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
51 #include <winsock.h>
52#endif
53//-----------------------------------------------------------------------------
54namespace tcp
55{
56 //---------------------------------------------------------------------------
57 #ifdef _MSC_VER
58 /* 'Bezeichner': Klasse 'Typ' benötigt eine DLL-Schnittstelle, die von... */
59 #pragma warning( disable : 4251 )
60 /* class 'TYP' ist keine DLL-Schnittstelle und wurde als Basisklasse... */
61 #pragma warning( disable : 4275 )
62 #endif
63 //---------------------------------------------------------------------------
64 //Forwards
65 class ClientReceiver;
66 class Transmitter;
67 //---------------------------------------------------------------------------
199 {
200 protected:
201 //============== Attribute
202 //-----------------------------------------------------------------------
214 //-----------------------------------------------------------------------
226 //-----------------------------------------------------------------------
227
228 private:
229 //============== Attribute
230 //-----------------------------------------------------------------------
240 SOCKADDR_IN m_Socketadress;
241 //-----------------------------------------------------------------------
251 std::string m_sHostname;
252 //-----------------------------------------------------------------------
262 std::queue<Message *> m_MsgQueue;
263 //-----------------------------------------------------------------------
289 //-----------------------------------------------------------------------
290
291 protected:
292 //============== Konstruktor
293 //-----------------------------------------------------------------------
304 //-----------------------------------------------------------------------
314 Client( unsigned int,
315 int,
316 int,
317 int,
318 int );
319 //-----------------------------------------------------------------------
320
321 public:
322 //============== Konstruktoren
323 //-----------------------------------------------------------------------
355 Client( const std::string & rsHostname,
356 unsigned int uiPort,
357 int iAdressFamily,
358 int iSocketType,
359 int iProtocol,
360 int iSecTimeOut );
361 //-----------------------------------------------------------------------
395 Client( const std::string & rsHostname,
396 unsigned int uiPort,
397 int iAdressFamily,
398 int iSocketType,
399 int iProtocol,
400 unsigned int uiDataSize,
401 int iSecTimeOut );
402 //-----------------------------------------------------------------------
403
404 //============== Destruktore
405 //-----------------------------------------------------------------------
417 virtual ~Client();
418 //-----------------------------------------------------------------------
419
420 private:
421 //============== Copy-Konstruktor
422 //-----------------------------------------------------------------------
432 Client( const Client & );
433 //-----------------------------------------------------------------------
434
435 protected:
436 //============== Methoden
437 //-----------------------------------------------------------------------
449 virtual void work() override;
450 //-----------------------------------------------------------------------
451 #if defined (__PTHREADS)
467 virtual void cleanUp();
468 //-----------------------------------------------------------------------
469 #else
470 //-----------------------------------------------------------------------
471
472 public:
473 //============== Methoden
485 virtual void cancel() override;
486 #endif
487 //-----------------------------------------------------------------------
488
489 protected:
490 //============== Methoden
491 //-----------------------------------------------------------------------
512 //-----------------------------------------------------------------------
533 //-----------------------------------------------------------------------
534
535 public:
536 //============== Methoden
537 //-----------------------------------------------------------------------
549 virtual void setDataSize( unsigned int uiDataSize ) override;
550 //-----------------------------------------------------------------------
563 //-----------------------------------------------------------------------
575 virtual int disconnectServer();
576 //-----------------------------------------------------------------------
588 bool isServerConnected() const;
589 //-----------------------------------------------------------------------
618 virtual int send( char * pszRawMsg,
619 unsigned int uiRawMsgSize,
620 unsigned int uiMessageID = 0,
621 int iActionCode = 0,
622 const std::string & rsInfo = "" );
623 //-----------------------------------------------------------------------
645 virtual int send( Message * pTcpMessage ) override;
646 //-----------------------------------------------------------------------
662 int acceptServerMessage( Message * pTcpServerMessage );
663 //-----------------------------------------------------------------------
679 int getSocketAdrFromString( SOCKADDR_IN * Socketadress,
680 const std::string & rsHostnameOrIp ) const;
681 //-----------------------------------------------------------------------
695 std::string getHostName() const;
696 //-----------------------------------------------------------------------
712 int getPeerName( std::string& rsIPAdress, unsigned int& ruiPort ) const;
713 //-----------------------------------------------------------------------
726 //-----------------------------------------------------------------------
727
728
729 protected:
730 //============== Methoden
731 //-----------------------------------------------------------------------
747 virtual void processServerMessage( Message * pTcpMessage );
748 //-----------------------------------------------------------------------
760 virtual int syncDataSize();
761 //-----------------------------------------------------------------------
762
763 private:
764 //============== Operatoren
765 //-----------------------------------------------------------------------
775 Client & operator= ( const Client & );
776 //-----------------------------------------------------------------------
777 };
778 //---------------------------------------------------------------------------
779 #ifdef _MSC_VER
780 /* 'Bezeichner': Klasse 'Typ' benötigt eine DLL-Schnittstelle, die von... */
781 #pragma warning( default : 4251 )
782 /* class 'TYP' ist keine DLL-Schnittstelle und wurde als Basisklasse... */
783 #pragma warning( default : 4275 )
784 #endif
785 //---------------------------------------------------------------------------
786} // namespace tcp
787//-----------------------------------------------------------------------------
788#endif
Header für TcpMain
Header für AbstractMessage, Message, ServerAcceptMessage und ServerMessage.
Header für ReceiverTransmitter.
Für jede Bibliothek, hier 'TcpLib' gibt es eine Typen-Datei.
#define __tcp_export_dll
Definition TcpTypes.h:59
Eine einfache TCP-Clientklasse, welche ihr KnowHow in den abgeleiteten Klassen lernen soll.
Definition TcpClient.h:199
Client(unsigned int, int, int, int, int)
bool isServerConnected() const
ClientReceiver * m_pReceiver
Definition TcpClient.h:213
ActionCode m_eToWaitingForServer
Definition TcpClient.h:288
std::queue< Message * > m_MsgQueue
Definition TcpClient.h:262
virtual void cancel() override
virtual int syncDataSize()
virtual int disconnectServer()
int acceptServerMessage(Message *pTcpServerMessage)
std::string m_sHostname
Definition TcpClient.h:251
int connectServer()
Client(const std::string &rsHostname, unsigned int uiPort, int iAdressFamily, int iSocketType, int iProtocol, int iSecTimeOut)
virtual int send(char *pszRawMsg, unsigned int uiRawMsgSize, unsigned int uiMessageID=0, int iActionCode=0, const std::string &rsInfo="")
virtual void processServerMessage(Message *pTcpMessage)
virtual ClientReceiver * generateNewReceiver()
int getPeerName(std::string &rsIPAdress, unsigned int &ruiPort) const
Transmitter * m_pTransmitter
Definition TcpClient.h:225
Client(const Client &)
virtual int send(Message *pTcpMessage) override
virtual ~Client()
SOCKADDR_IN m_Socketadress
Definition TcpClient.h:240
virtual void work() override
Client(const std::string &rsHostname, unsigned int uiPort, int iAdressFamily, int iSocketType, int iProtocol, unsigned int uiDataSize, int iSecTimeOut)
ActionCode getWaitingServerMsgActionCode() const
virtual void setDataSize(unsigned int uiDataSize) override
std::string getHostName() const
virtual Transmitter * generateNewTransmitter()
int getSocketAdrFromString(SOCKADDR_IN *Socketadress, const std::string &rsHostnameOrIp) const
Klasse, welche über ein SOCKET mit einem Server kommunizieret und ihr Empfangsergebnis vom Typ Messag...
Definition TcpClientReceiver.h:81
Beinhaltet einen Datenstrom, welcher von den Tcp-Klassen versendet und empfangen werden kann.
Definition TcpMessage.h:168
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
ActionCode
Definition TcpTypes.h:124