SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SLNet::TCPInterface Class Reference

`#include <slikenet/TCPInterface.h>`

Inheritance diagram for SLNet::TCPInterface:

## Classes

struct | ThisPtrPlusSysAddr

## Public Member Functions

| TCPInterface ()
virtual | ~TCPInterface ()
bool | Start (unsigned short port, unsigned short maxIncomingConnections, unsigned short maxConnections=0, int _threadPriority=-99999, unsigned short socketFamily=AF_INET, const char *bindAddress=0)
void | Stop (void)
| Stops the TCP server.
SystemAddress | Connect (const char *host, unsigned short remotePort, bool block=true, unsigned short socketFamily=AF_INET, const char *bindAddress=0)
| Connect to the specified host on the specified port.
virtual void | Send (const char *data, unsigned int length, const SystemAddress &systemAddress, bool broadcast)
| Sends a byte stream.
virtual bool | SendList (const char **data, const unsigned int *lengths, const int numParameters, const SystemAddress &systemAddress, bool broadcast)
unsigned int | GetOutgoingDataBufferSize (SystemAddress systemAddress) const
virtual bool | ReceiveHasPackets (void)
virtual 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)
bool | WasStarted (void) const
| Returns if Start() was called successfully.
void | AttachPlugin (PluginInterface2 *plugin)
void | DetachPlugin (PluginInterface2 *plugin)

## Protected Member Functions

Packet * | ReceiveInt (void)
bool | CreateListenSocket (unsigned short port, unsigned short maxIncomingConnections, unsigned short socketFamily, const char *hostAddress)
friend | RAK_THREAD_DECLARATION (UpdateTCPInterfaceLoop)
friend | RAK_THREAD_DECLARATION (ConnectionAttemptLoop)
__TCPSOCKET__ | SocketConnect (const char *host, unsigned short remotePort, unsigned short socketFamily, const char *bindAddress)

## Protected Attributes

DataStructures::List < PluginInterface2 * > | messageHandlerList
SLNet::LocklessUint32_t | isStarted
SLNet::LocklessUint32_t | threadRunning
__TCPSOCKET__ | listenSocket
DataStructures::Queue< Packet * > | headPush
DataStructures::Queue< Packet * > | tailPush
RemoteClient * | remoteClients
unsigned short | 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 < __TCPSOCKET__ > | blockingSocketList
SimpleMutex | blockingSocketListMutex

## Detailed Description

Definition at line 56 of file TCPInterface.h.

## Class Documentation

struct SLNet::TCPInterface::ThisPtrPlusSysAddr

Definition at line 205 of file TCPInterface.h.

Class Members
char | bindAddress |
unsigned short | socketFamily |
SystemAddress | systemAddress |
TCPInterface * | tcpInterface |
bool | useSSL |

## Constructor & Destructor Documentation

SLNet::TCPInterface::TCPInterface | ( |  | ) |

virtual SLNet::TCPInterface::~TCPInterface | ( |  | ) |

virtual

## Member Function Documentation

Packet* SLNet::TCPInterface::AllocatePacket | ( | unsigned | dataSize | ) |

Return an allocated but empty packet, for custom use.

Referenced by SLNet::PluginInterface2::AllocatePacketUnified().

void SLNet::TCPInterface::AttachPlugin | ( | PluginInterface2 * | plugin | ) |

void SLNet::TCPInterface::CloseConnection | ( | SystemAddress | systemAddress | ) |

Disconnects a player/address.

SystemAddress SLNet::TCPInterface::Connect | ( | const char * | host,
|  | unsigned short | remotePort,
|  | bool | block = `true`,
|  | unsigned short | socketFamily = `AF_INET`,
|  | const char * | bindAddress = `0`
| ) |  |

Connect to the specified host on the specified port.

bool SLNet::TCPInterface::CreateListenSocket | ( | unsigned short | port,
|  | unsigned short | maxIncomingConnections,
|  | unsigned short | socketFamily,
|  | const char * | hostAddress
| ) |  |

protected

void SLNet::TCPInterface::DeallocatePacket | ( | Packet * | packet | ) |

Deallocates a packet returned by Receive.

Referenced by SLNet::PluginInterface2::DeallocPacketUnified().

void SLNet::TCPInterface::DetachPlugin | ( | PluginInterface2 * | plugin | ) |

unsigned short SLNet::TCPInterface::GetConnectionCount | ( | void |  | ) | const

Returns just the number of connections we have.

void SLNet::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

unsigned int SLNet::TCPInterface::GetOutgoingDataBufferSize | ( | SystemAddress | systemAddress | ) | const

SystemAddress SLNet::TCPInterface::HasCompletedConnectionAttempt | ( | void |  | ) |

Has a previous call to connect succeeded?

Returns
  UNASSIGNED_SYSTEM_ADDRESS = no. Anything else means yes.

SystemAddress SLNet::TCPInterface::HasFailedConnectionAttempt | ( | void |  | ) |

Has a previous call to connect failed?

Returns
  UNASSIGNED_SYSTEM_ADDRESS = no. Anything else means yes.

SystemAddress SLNet::TCPInterface::HasLostConnection | ( | void |  | ) |

Queued events of lost connections.

SystemAddress SLNet::TCPInterface::HasNewIncomingConnection | ( | void |  | ) |

Queued events of new incoming connections.

virtual void SLNet::TCPInterface::PushBackPacket | ( | Packet * | packet,
|  | bool | pushAtHead
| ) |  |

virtual

Referenced by SLNet::PluginInterface2::PushBackPacketUnified().

SLNet::TCPInterface::RAK_THREAD_DECLARATION | ( | UpdateTCPInterfaceLoop |  | ) |

protected

SLNet::TCPInterface::RAK_THREAD_DECLARATION | ( | ConnectionAttemptLoop |  | ) |

protected

virtual Packet* SLNet::TCPInterface::Receive | ( | void |  | ) |

virtual

Returns data received.

Reimplemented in SLNet::PacketizedTCP.

virtual bool SLNet::TCPInterface::ReceiveHasPackets | ( | void |  | ) |

virtual

Returns if Receive() will return data Do not use on PacketizedTCP

Packet* SLNet::TCPInterface::ReceiveInt | ( | void |  | ) |

protected

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

virtual

Sends a byte stream.

Referenced by SLNet::PluginInterface2::SendUnified().

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

virtual

Reimplemented in SLNet::PacketizedTCP.

Referenced by SLNet::PluginInterface2::SendListUnified().

__TCPSOCKET__ SLNet::TCPInterface::SocketConnect | ( | const char * | host,
|  | unsigned short | remotePort,
|  | unsigned short | socketFamily,
|  | const char * | bindAddress
| ) |  |

protected

bool SLNet::TCPInterface::Start | ( | unsigned short | port,
|  | unsigned short | maxIncomingConnections,
|  | unsigned short | maxConnections = `0`,
|  | int | _threadPriority = `-99999`,
|  | unsigned short | socketFamily = `AF_INET`,
|  | const char * | bindAddress = `0`
| ) |  |

Starts the TCP server on the indicated port

Parameters

  [in] | port | Which port to listen on.
  [in] | maxIncomingConnections | Max incoming connections we will accept
  [in] | maxConnections | Max total connections, which should be >= maxIncomingConnections
  [in] | threadPriority | Passed to the thread creation routine. Use THREAD_PRIORITY_NORMAL for Windows. For Linux based systems, you MUST pass something reasonable based on the thread priorities for your application.
  [in] | socketFamily | IP version: For IPV4, use AF_INET (default). For IPV6, use AF_INET6. To autoselect, use AF_UNSPEC.

void SLNet::TCPInterface::Stop | ( | void |  | ) |

Stops the TCP server.

bool SLNet::TCPInterface::WasStarted | ( | void |  | ) | const

Returns if Start() was called successfully.

## Member Data Documentation

DataStructures::List<__TCPSOCKET__> SLNet::TCPInterface::blockingSocketList

protected

Definition at line 191 of file TCPInterface.h.

SimpleMutex SLNet::TCPInterface::blockingSocketListMutex

protected

Definition at line 192 of file TCPInterface.h.

SimpleMutex SLNet::TCPInterface::completedConnectionAttemptMutex

protected

Definition at line 186 of file TCPInterface.h.

DataStructures::Queue<SystemAddress> SLNet::TCPInterface::completedConnectionAttempts

protected

Definition at line 187 of file TCPInterface.h.

SimpleMutex SLNet::TCPInterface::failedConnectionAttemptMutex

protected

Definition at line 186 of file TCPInterface.h.

DataStructures::Queue<SystemAddress> SLNet::TCPInterface::failedConnectionAttempts

protected

Definition at line 187 of file TCPInterface.h.

DataStructures::Queue<Packet*> SLNet::TCPInterface::headPush

protected

Definition at line 159 of file TCPInterface.h.

DataStructures::ThreadsafeAllocatingQueue<Packet> SLNet::TCPInterface::incomingMessages

protected

Definition at line 183 of file TCPInterface.h.

SLNet::LocklessUint32_t SLNet::TCPInterface::isStarted

protected

Definition at line 156 of file TCPInterface.h.

__TCPSOCKET__ SLNet::TCPInterface::listenSocket

protected

Definition at line 157 of file TCPInterface.h.

DataStructures::ThreadsafeAllocatingQueue<SystemAddress> SLNet::TCPInterface::lostConnections

protected

Definition at line 184 of file TCPInterface.h.

DataStructures::List<PluginInterface2*> SLNet::TCPInterface::messageHandlerList

protected

Definition at line 154 of file TCPInterface.h.

DataStructures::ThreadsafeAllocatingQueue<SystemAddress> SLNet::TCPInterface::newIncomingConnections

protected

Definition at line 184 of file TCPInterface.h.

DataStructures::ThreadsafeAllocatingQueue<RemoteClient*> SLNet::TCPInterface::newRemoteClients

protected

Definition at line 185 of file TCPInterface.h.

RemoteClient* SLNet::TCPInterface::remoteClients

protected

Definition at line 160 of file TCPInterface.h.

unsigned short SLNet::TCPInterface::remoteClientsLength

protected

Definition at line 161 of file TCPInterface.h.

DataStructures::ThreadsafeAllocatingQueue<SystemAddress> SLNet::TCPInterface::requestedCloseConnections

protected

Definition at line 184 of file TCPInterface.h.

DataStructures::Queue<Packet*> SLNet::TCPInterface::tailPush

protected

Definition at line 159 of file TCPInterface.h.

int SLNet::TCPInterface::threadPriority

protected

Definition at line 189 of file TCPInterface.h.

SLNet::LocklessUint32_t SLNet::TCPInterface::threadRunning

protected

Definition at line 156 of file TCPInterface.h.

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

- Source/include/slikenet/TCPInterface.h