![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cNetServer.h>
Public Attributes | |
| const char * | m_pszServerName |
| Server type name. (not host name) More... | |
| const bool | m_bAsyncEvents |
| _WIN32 only. use async callbacks. More... | |
| int | m_nMaxConnections |
| total allowed incoming connections. More... | |
| int | m_nMaxPerAddr |
| max connections per host/address. More... | |
| int | m_nMaxPerAddrUnresolved |
| max unresolved protocol connections per host/address. More... | |
Public Attributes inherited from GrayLib::cNetServerGroup | |
| cNetServer & | m_server |
| My top level cNetServer owner/parent. More... | |
| cValueStatsRate< float > | m_TickLatency |
| How long did the last OnTickSelect and OnTickClients take ? TIMESYS_t. More... | |
Public Attributes inherited from Gray::cStreamStats | |
| cStreamStat | m_StatOut |
| cStreamStat | m_StatInp |
Protected Member Functions | |
| void | OnClientCloseComplete () |
| HRESULT | TestProtocolClient (cNetServerConnection *pClient) |
| HRESULT | OnEventAccept (cNetServerPort *pListenPort, LSTATUS wError) |
| HRESULT | OnClientConnect (cNetServerConnection *pClient) |
| virtual HRESULT | OnClientReady (cNetServerConnection *pClient) |
| virtual void | OnClientClose (cNetServerConnection *pClient) |
| virtual HRESULT | OnClientRead (cNetServerConnection *pClient) override |
Protected Member Functions inherited from GrayLib::cNetServerGroup | |
| HRESULT | OnClientWrite (cNetServerConnection *pClient) |
| HRESULT | OnTickSelect (TIMESYSD_t tWaitMax, cNetSocketSet &readfds, cNetSocketSet &writefds) |
Protected Attributes | |
| cNetSystemPtr | m_NetSystem |
| I use the network. More... | |
| cArrayRef< cNetServerThread > | m_aThreads |
| Alternate threads used to process clients. More... | |
| cArraySortHash< cNetServerConnection > | m_aConnecting |
| My Outgoing connections. From this server to some place. More... | |
| cThreadLockArrayHash< cNetServerConnection > | m_aClosing |
| Call OnClientClose these connections. More... | |
| cArraySortHash< cNetServerPort > | m_aListenPorts |
| The server SOCKET(s) we are currently listening on. 1 for each port. More... | |
Protected Attributes inherited from GrayLib::cProtocolFactories | |
| cArrayPtr< IProtocolFactory > | m_aProtocols |
| array of possible protocols we support. More... | |
Protected Attributes inherited from GrayLib::cNetServerGroup | |
| cThreadLockArrayHash< cNetServerConnection > | m_aConnections |
| Collection of active clients. sorted by socket id. More... | |
Friends | |
| class | cNetServerGroup |
A generic TCP Internet server for things based on cProtocol. Accept incoming TCP connections and manage them. Can act as a polled server or just waits for incoming connections.
| GrayLib::cNetServer::cNetServer | ( | const char * | pszName = "NetServer", |
| bool | bAsyncEvents = false |
||
| ) |
|
virtual |
| HRESULT GrayLib::cNetServer::AddListenPort | ( | cNetServerPort * | pServerPort | ) |
Monitor/listen on this new local socket address/port.
| HRESULT GrayLib::cNetServer::AddListenPort | ( | const cNetAddress & | SockAddr | ) |
Monitor/listen on this new local socket address/port.
| HRESULT GrayLib::cNetServer::AddListenPort2 | ( | const cNetAddress & | SockAddr, |
| OUT cNetServerPortPtr * | ppServerPort = nullptr |
||
| ) |
Monitor/listen on this new local socket address/port.
|
virtual |
Is the address on my blocked list ? override to use cNetAddrMgr/cNetAddrTracker Different clients behind a NAT IP host router can all look like the same address to me. just different ports. Does this host address have other unresolved connections? (only c_MaxUnresolvedPerAddr allowed at a time) Prevent DoS attacks.
| void GrayLib::cNetServer::CloseServer | ( | ) |
server is going away.
remove server SOCKET(s) we are currently listening on. 1 for each port.
| HRESULT GrayLib::cNetServer::CreateServerStream | ( | const cNetAddress & | addr, |
| IProtocolFactory & | pf, | ||
| cNetServerConnectionPtr & | rpStream | ||
| ) |
Create an outgoing stream/protocol connection. Weird behavior for a server. But treat it like any other server connection. e.g. FTP server does outgoing connect for NOT PASV data connection.
|
inline |
|
inlinenoexcept |
Sum of all ports I must poll.
|
inlinenoexcept |
How many ports/sockets am i listening to ?
|
inlinenoexcept |
| bool GrayLib::cNetServer::InitServer | ( | ) |
Make sure the server has connected to the network.
|
protectedvirtual |
The socket has disconnected so clean it up. a remote disconnect or graceful disconnect. Assume debug message already posted.
|
protected |
call OnClientClose all the clients that are m_aClosing.
|
protected |
Outgoing (non blocking) connection is now connected. FD_CONNECT Failure to complete connection just calls OnClientClose
|
overrideprotectedvirtual |
Data is ready for read on a client connection. FD_READ
Reimplemented from GrayLib::cNetServerGroup.
|
protectedvirtual |
The connections/clients m_pProtocol has been resolved and/or connected. override this to reject protocols on certain addresses/protocol combos ?
|
protected |
The system says a new connection is incoming via ::select() or asynchronous FD_ACCEPT message. Accept incoming connection and find out more about this connection.
|
overridevirtual |
OnTick + Final cleanup of closed clients.
Reimplemented from GrayLib::cNetServerGroup.
| void GrayLib::cNetServer::OnTickServer | ( | TIMESYSD_t | tWaitMax = 0 | ) |
Poll of listen sockets and process data from clients.
| bool GrayLib::cNetServer::RemoveListenPort | ( | cNetServerPort * | pServerPort | ) |
When a particular listen socket is no longer needed. remove it.
|
protected |
We just got data for this new incoming client. Try to resolve its protocol.
| GrayLib::cNetServer::UNITTEST_FRIEND | ( | cNetServer | ) |
|
friend |
|
protected |
Call OnClientClose these connections.
|
protected |
My Outgoing connections. From this server to some place.
|
protected |
The server SOCKET(s) we are currently listening on. 1 for each port.
|
protected |
Alternate threads used to process clients.
| const bool GrayLib::cNetServer::m_bAsyncEvents |
_WIN32 only. use async callbacks.
|
protected |
I use the network.
| int GrayLib::cNetServer::m_nMaxConnections |
total allowed incoming connections.
| int GrayLib::cNetServer::m_nMaxPerAddr |
max connections per host/address.
| int GrayLib::cNetServer::m_nMaxPerAddrUnresolved |
max unresolved protocol connections per host/address.
| const char* GrayLib::cNetServer::m_pszServerName |
Server type name. (not host name)