#include <TCPInterface.h>
Inherited by PacketizedTCP.
Classes | |
struct | ThisPtrPlusSysAddr |
Public Member Functions | |
TCPInterface () | |
virtual | ~TCPInterface () |
bool | Start (unsigned short port, unsigned short maxIncomingConnections, unsigned short maxConnections=0, int _threadPriority=-99999) |
void | Stop (void) |
Stops the TCP server. | |
SystemAddress | Connect (const char *host, unsigned short remotePort, bool block=true) |
Connect to the specified host on the specified port. | |
void | Send (const char *data, unsigned int length, SystemAddress systemAddress, bool broadcast) |
Sends a byte stream. | |
bool | SendList (const char **data, const unsigned int *lengths, const int numParameters, SystemAddress systemAddress, bool broadcast) |
unsigned int | GetOutgoingDataBufferSize (SystemAddress systemAddress) const |
bool | ReceiveHasPackets (void) |
Returns if Receive() will return data. | |
Packet * | Receive (void) |
Returns data received. | |
void | CloseConnection (SystemAddress systemAddress) |
Disconnects a player/address. | |
void | DeallocatePacket (Packet *packet) |
Deallocates a packet returned by Receive. | |
void | GetConnectionList (SystemAddress *remoteSystems, unsigned short *numberOfSystems) const |
unsigned short | GetConnectionCount (void) const |
Returns just the number of connections we have. | |
SystemAddress | HasCompletedConnectionAttempt (void) |
SystemAddress | HasFailedConnectionAttempt (void) |
SystemAddress | HasNewIncomingConnection (void) |
Queued events of new incoming connections. | |
SystemAddress | HasLostConnection (void) |
Queued events of lost connections. | |
Packet * | AllocatePacket (unsigned dataSize) |
Return an allocated but empty packet, for custom use. | |
virtual void | PushBackPacket (Packet *packet, bool pushAtHead) |
Protected Member Functions | |
friend | RAK_THREAD_DECLARATION (UpdateTCPInterfaceLoop) |
friend | RAK_THREAD_DECLARATION (ConnectionAttemptLoop) |
SOCKET | SocketConnect (const char *host, unsigned short remotePort) |
Protected Attributes | |
bool | isStarted |
bool | threadRunning |
SOCKET | listenSocket |
DataStructures::Queue< Packet * > | headPush |
DataStructures::Queue< Packet * > | tailPush |
RemoteClient * | remoteClients |
int | remoteClientsLength |
DataStructures::ThreadsafeAllocatingQueue < Packet > | incomingMessages |
DataStructures::ThreadsafeAllocatingQueue < SystemAddress > | newIncomingConnections |
DataStructures::ThreadsafeAllocatingQueue < SystemAddress > | lostConnections |
DataStructures::ThreadsafeAllocatingQueue < SystemAddress > | requestedCloseConnections |
DataStructures::ThreadsafeAllocatingQueue < RemoteClient * > | newRemoteClients |
SimpleMutex | completedConnectionAttemptMutex |
SimpleMutex | failedConnectionAttemptMutex |
DataStructures::Queue < SystemAddress > | completedConnectionAttempts |
DataStructures::Queue < SystemAddress > | failedConnectionAttempts |
int | threadPriority |
DataStructures::List< SOCKET > | blockingSocketList |
SimpleMutex | blockingSocketListMutex |
Definition at line 38 of file TCPInterface.h.
TCPInterface::TCPInterface | ( | ) |
TCPInterface::~TCPInterface | ( | ) | [virtual] |
Packet * TCPInterface::AllocatePacket | ( | unsigned | dataSize | ) |
Return an allocated but empty packet, for custom use.
Definition at line 414 of file TCPInterface.cpp.
void TCPInterface::CloseConnection | ( | SystemAddress | systemAddress | ) |
Disconnects a player/address.
Reimplemented in PacketizedTCP.
Definition at line 365 of file TCPInterface.cpp.
SystemAddress TCPInterface::Connect | ( | const char * | host, | |
unsigned short | remotePort, | |||
bool | block = true | |||
) |
Connect to the specified host on the specified port.
Definition at line 200 of file TCPInterface.cpp.
void TCPInterface::DeallocatePacket | ( | Packet * | packet | ) |
Deallocates a packet returned by Receive.
Definition at line 398 of file TCPInterface.cpp.
unsigned short TCPInterface::GetConnectionCount | ( | void | ) | const |
Returns just the number of connections we have.
Definition at line 496 of file TCPInterface.cpp.
void TCPInterface::GetConnectionList | ( | SystemAddress * | remoteSystems, | |
unsigned short * | numberOfSystems | |||
) | const |
Fills the array remoteSystems with the SystemAddress of all the systems we are connected to
[out] | remoteSystems | An array of SystemAddress structures to be filled with the SystemAddresss of the systems we are connected to. Pass 0 to remoteSystems to only get the number of systems we are connected to |
[in,out] | numberOfSystems | As input, the size of remoteSystems array. As output, the number of elements put into the array |
Definition at line 481 of file TCPInterface.cpp.
unsigned int TCPInterface::GetOutgoingDataBufferSize | ( | SystemAddress | systemAddress | ) | const |
SystemAddress TCPInterface::HasCompletedConnectionAttempt | ( | void | ) |
Has a previous call to connect succeeded?
Reimplemented in PacketizedTCP.
Definition at line 433 of file TCPInterface.cpp.
SystemAddress TCPInterface::HasFailedConnectionAttempt | ( | void | ) |
Has a previous call to connect failed?
Reimplemented in PacketizedTCP.
Definition at line 442 of file TCPInterface.cpp.
SystemAddress TCPInterface::HasLostConnection | ( | void | ) |
Queued events of lost connections.
Reimplemented in PacketizedTCP.
Definition at line 466 of file TCPInterface.cpp.
SystemAddress TCPInterface::HasNewIncomingConnection | ( | void | ) |
Queued events of new incoming connections.
Reimplemented in PacketizedTCP.
Definition at line 451 of file TCPInterface.cpp.
void TCPInterface::PushBackPacket | ( | Packet * | packet, | |
bool | pushAtHead | |||
) | [virtual] |
Definition at line 426 of file TCPInterface.cpp.
TCPInterface::RAK_THREAD_DECLARATION | ( | UpdateTCPInterfaceLoop | ) | [protected] |
TCPInterface::RAK_THREAD_DECLARATION | ( | ConnectionAttemptLoop | ) | [protected] |
Packet * TCPInterface::Receive | ( | void | ) |
Returns data received.
Reimplemented in PacketizedTCP.
Definition at line 352 of file TCPInterface.cpp.
bool TCPInterface::ReceiveHasPackets | ( | void | ) |
Returns if Receive() will return data.
Definition at line 348 of file TCPInterface.cpp.
void TCPInterface::Send | ( | const char * | data, | |
unsigned int | length, | |||
SystemAddress | systemAddress, | |||
bool | broadcast | |||
) |
Sends a byte stream.
bool TCPInterface::SendList | ( | const char ** | data, | |
const unsigned int * | lengths, | |||
const int | numParameters, | |||
SystemAddress | systemAddress, | |||
bool | broadcast | |||
) |
SOCKET TCPInterface::SocketConnect | ( | const char * | host, | |
unsigned short | remotePort | |||
) | [protected] |
Definition at line 531 of file TCPInterface.cpp.
bool TCPInterface::Start | ( | unsigned short | port, | |
unsigned short | maxIncomingConnections, | |||
unsigned short | maxConnections = 0 , |
|||
int | _threadPriority = -99999 | |||
) |
Starts the TCP server on the indicated port
[in] | threadPriority | Passed to thread creation routine. Use THREAD_PRIORITY_NORMAL for Windows. WARNING!!! On Linux, 0 means highest priority! You MUST set this to something valid based on the values used by your other threads |
Definition at line 74 of file TCPInterface.cpp.
void TCPInterface::Stop | ( | void | ) |
Stops the TCP server.
Reimplemented in PacketizedTCP.
Definition at line 129 of file TCPInterface.cpp.
DataStructures::List<SOCKET> TCPInterface::blockingSocketList [protected] |
Definition at line 147 of file TCPInterface.h.
SimpleMutex TCPInterface::blockingSocketListMutex [protected] |
Definition at line 148 of file TCPInterface.h.
Definition at line 142 of file TCPInterface.h.
Definition at line 143 of file TCPInterface.h.
Definition at line 142 of file TCPInterface.h.
Definition at line 143 of file TCPInterface.h.
DataStructures::Queue<Packet*> TCPInterface::headPush [protected] |
Definition at line 115 of file TCPInterface.h.
Definition at line 139 of file TCPInterface.h.
bool TCPInterface::isStarted [protected] |
Definition at line 112 of file TCPInterface.h.
SOCKET TCPInterface::listenSocket [protected] |
Definition at line 113 of file TCPInterface.h.
Definition at line 140 of file TCPInterface.h.
DataStructures::ThreadsafeAllocatingQueue<SystemAddress> TCPInterface::newIncomingConnections [protected] |
Definition at line 140 of file TCPInterface.h.
Definition at line 141 of file TCPInterface.h.
RemoteClient* TCPInterface::remoteClients [protected] |
Definition at line 116 of file TCPInterface.h.
int TCPInterface::remoteClientsLength [protected] |
Definition at line 117 of file TCPInterface.h.
DataStructures::ThreadsafeAllocatingQueue<SystemAddress> TCPInterface::requestedCloseConnections [protected] |
Definition at line 140 of file TCPInterface.h.
DataStructures::Queue<Packet*> TCPInterface::tailPush [protected] |
Definition at line 115 of file TCPInterface.h.
int TCPInterface::threadPriority [protected] |
Definition at line 145 of file TCPInterface.h.
bool TCPInterface::threadRunning [protected] |
Definition at line 112 of file TCPInterface.h.