Classes | Public Member Functions | Protected Member Functions | Protected Attributes

TCPInterface Class Reference

#include <TCPInterface.h>

Inherited by PacketizedTCP.

Collaboration diagram for TCPInterface:
Collaboration graph
[legend]

List of all members.

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.
PacketReceive (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.
PacketAllocatePacket (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
RemoteClientremoteClients
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< SOCKETblockingSocketList
SimpleMutex blockingSocketListMutex

Detailed Description

Definition at line 38 of file TCPInterface.h.


Constructor & Destructor Documentation

TCPInterface::TCPInterface (  ) 

Definition at line 42 of file TCPInterface.cpp.

Here is the call graph for this function:

TCPInterface::~TCPInterface (  )  [virtual]

Definition at line 62 of file TCPInterface.cpp.

Here is the call graph for this function:


Member Function Documentation

Packet * TCPInterface::AllocatePacket ( unsigned  dataSize  ) 

Return an allocated but empty packet, for custom use.

Definition at line 414 of file TCPInterface.cpp.

Here is the caller graph for this function:

void TCPInterface::CloseConnection ( SystemAddress  systemAddress  ) 

Disconnects a player/address.

Reimplemented in PacketizedTCP.

Definition at line 365 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

void TCPInterface::DeallocatePacket ( Packet packet  ) 

Deallocates a packet returned by Receive.

Definition at line 398 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
[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

Definition at line 507 of file TCPInterface.cpp.

Here is the call graph for this function:

SystemAddress TCPInterface::HasCompletedConnectionAttempt ( void   ) 

Has a previous call to connect succeeded?

Returns:
UNASSIGNED_SYSTEM_ADDRESS = no. Anything else means yes.

Reimplemented in PacketizedTCP.

Definition at line 433 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

SystemAddress TCPInterface::HasFailedConnectionAttempt ( void   ) 

Has a previous call to connect failed?

Returns:
UNASSIGNED_SYSTEM_ADDRESS = no. Anything else means yes.

Reimplemented in PacketizedTCP.

Definition at line 442 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

SystemAddress TCPInterface::HasLostConnection ( void   ) 

Queued events of lost connections.

Reimplemented in PacketizedTCP.

Definition at line 466 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

SystemAddress TCPInterface::HasNewIncomingConnection ( void   ) 

Queued events of new incoming connections.

Reimplemented in PacketizedTCP.

Definition at line 451 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void TCPInterface::PushBackPacket ( Packet packet,
bool  pushAtHead 
) [virtual]

Definition at line 426 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

bool TCPInterface::ReceiveHasPackets ( void   ) 

Returns if Receive() will return data.

Definition at line 348 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void TCPInterface::Send ( const char *  data,
unsigned int  length,
SystemAddress  systemAddress,
bool  broadcast 
)

Sends a byte stream.

Here is the caller graph for this function:

bool TCPInterface::SendList ( const char **  data,
const unsigned int *  lengths,
const int  numParameters,
SystemAddress  systemAddress,
bool  broadcast 
)

Definition at line 296 of file TCPInterface.cpp.

Here is the call graph for this function:

SOCKET TCPInterface::SocketConnect ( const char *  host,
unsigned short  remotePort 
) [protected]

Definition at line 531 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool TCPInterface::Start ( unsigned short  port,
unsigned short  maxIncomingConnections,
unsigned short  maxConnections = 0,
int  _threadPriority = -99999 
)

Starts the TCP server on the indicated port

Parameters:
[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.

Here is the call graph for this function:

Here is the caller graph for this function:

void TCPInterface::Stop ( void   ) 

Stops the TCP server.

Reimplemented in PacketizedTCP.

Definition at line 129 of file TCPInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 147 of file TCPInterface.h.

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.

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.

Definition at line 113 of file TCPInterface.h.

Definition at line 140 of file TCPInterface.h.

Definition at line 140 of file TCPInterface.h.

Definition at line 141 of file TCPInterface.h.

Definition at line 116 of file TCPInterface.h.

Definition at line 117 of file TCPInterface.h.

Definition at line 140 of file TCPInterface.h.

Definition at line 115 of file TCPInterface.h.

Definition at line 145 of file TCPInterface.h.

bool TCPInterface::threadRunning [protected]

Definition at line 112 of file TCPInterface.h.


The documentation for this class was generated from the following files: