Superclass for Client and Server, which 'learns' its know-how in the derived classes.
More...
#include <TcpMain.h>
Superclass for Client and Server, which 'learns' its know-how in the derived classes.
- Copyright
- © 2010 Helmut Jakoby
- Author
- Helmut Jakoby
◆ TcpMain() [1/4]
tcp::TcpMain::TcpMain |
( |
| ) |
|
|
protected |
This constructor is not available.
◆ TcpMain() [2/4]
tcp::TcpMain::TcpMain |
( |
unsigned int | uiPort, |
|
|
int | iAdressFamily, |
|
|
int | iSocketType, |
|
|
int | iProtocol, |
|
|
int | iSecTimeOut ) |
Constructor with parameter passing.
- Parameters
-
[in] | uiPort | The port of the server. |
[in] | iAdressFamily | The socket address family to instantiate a socket (usually AF_INET). |
[in] | iSocketType | The socket type (usually SOCK_STREAM). |
[in] | iProtocol | The socket protocol (usually 0). |
[in] | iSecTimeOut | The time until waiting for a connection or waiting for data is aborted. |
It is started under Windows WSA.
- Exceptions
-
◆ TcpMain() [3/4]
tcp::TcpMain::TcpMain |
( |
unsigned int | uiPort, |
|
|
int | iAdressFamily, |
|
|
int | iSocketType, |
|
|
int | iProtocol, |
|
|
unsigned int | uiDataSize, |
|
|
int | iSecTimeOut ) |
Constructor with parameter passing.
- Parameters
-
[in] | uiPort | The port of the server. |
[in] | iAdressFamily | The socket address family to instantiate a socket (usually AF_INET). |
[in] | iSocketType | The socket type (usually SOCK_STREAM). |
[in] | iProtocol | The socket protocol (usually 0). |
[in] | uiDataSize | The packet size. |
[in] | iSecTimeOut | The time until waiting for a connection or waiting for data is aborted. |
It is started under Windows WSA.
- Exceptions
-
◆ ~TcpMain()
virtual tcp::TcpMain::~TcpMain |
( |
| ) |
|
|
virtual |
Destructor. It is terminated under Windows WSA.
◆ TcpMain() [4/4]
tcp::TcpMain::TcpMain |
( |
const TcpMain & | | ) |
|
|
private |
The copy constructor is not available.
◆ getDataSize()
unsigned int tcp::TcpMain::getDataSize |
( |
| ) |
const |
◆ getMainSocket()
SOCKET tcp::TcpMain::getMainSocket |
( |
| ) |
const |
◆ getPortNum()
unsigned int tcp::TcpMain::getPortNum |
( |
| ) |
const |
◆ operator=()
The assignment operator is not available.
◆ send()
virtual int tcp::TcpMain::send |
( |
Message * | pTcpMessage | ) |
|
|
pure virtual |
Sends transferred Message to the counterpart.
If This is a client, the counterpart is the server. If This is a server, the counterpart is the server. Sends transferred message to the counterpart socket referenced there.
The implementation is executed in the subclass.
- Parameters
-
[in] | pTcpMessage | The message to be sent. |
- Returns
- A return < 0 indicates an error.
Implemented in tcp::Client, and tcp::Server.
◆ setDataSize()
virtual void tcp::TcpMain::setDataSize |
( |
unsigned int | uiDataSize | ) |
|
|
virtual |
Sets the packet size.
- Parameters
-
[in] | uiDataSize | The package size must be greater than 0. |
- Exceptions
-
Reimplemented in tcp::Client.
◆ setTimeOutSec()
void tcp::TcpMain::setTimeOutSec |
( |
int | iSecTimeOut | ) |
|
Sets the seconds to wait for responses.
- Parameters
-
[in] | iSecTimeOut | The maximum waiting time. |
◆ setWSACleanup()
void tcp::TcpMain::setWSACleanup |
( |
| ) |
const |
|
protected |
It decrements m_uiTcpMainCounter and on Windows if 0, calls WSACleanup() (closes ALL connections)
◆ startWinsock()
int tcp::TcpMain::startWinsock |
( |
| ) |
const |
|
protected |
It is started under Windows WSA using WSAStartup().
- Returns
- A return value < 0 indicates an error.
◆ TimeOutSec()
int tcp::TcpMain::TimeOutSec |
( |
| ) |
|
Returns the seconds how long the system waits for answers.
- Returns
- The maximum waiting time.
◆ m_iAdressFamily
int tcp::TcpMain::m_iAdressFamily |
|
protected |
The Socket AddressFamily (usually AF_INET) to instantiate a socket.
◆ m_iProtocol
int tcp::TcpMain::m_iProtocol |
|
protected |
The socket protocol (usually 0) to instantiate a socket.
◆ m_iSecTimeOut
int tcp::TcpMain::m_iSecTimeOut |
|
protected |
Waiting time for connection responses. if not set, the wait may be eternal!
◆ m_iSocketType
int tcp::TcpMain::m_iSocketType |
|
protected |
The socket type (usually SOCK_STREAM) to instantiate a socket.
◆ m_MainSocket
SOCKET tcp::TcpMain::m_MainSocket |
|
protected |
◆ m_uiDataSize
unsigned int tcp::TcpMain::m_uiDataSize |
|
protected |
Packets are made from the data stream; here the packet size (default is DEFAULT_DATASIZE).
◆ m_uiServerPort
unsigned int tcp::TcpMain::m_uiServerPort |
|
protected |
◆ m_uiTcpMainCounter
unsigned int tcp::TcpMain::m_uiTcpMainCounter |
|
staticprivate |
This counter is incremented each time an object of this class or subclass is instantiated. With each call to setWSACleanup() it is decremented again.
- See also
- setWSACleanup()
The documentation for this class was generated from the following file: