Open 3D Engine GridMate API Reference  2205.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
GridMate::StreamSocketDriver Class Reference

#include <StreamSocketDriver.h>

Inherits GridMate::SocketDriver.

Classes

class  Connection
 
struct  Packet
 
class  RingBuffer
 
struct  SocketPtrHasher
 

Public Types

using SocketDriverAddressPtr = AZStd::intrusive_ptr< SocketDriverAddress >
 
- Public Types inherited from GridMate::SocketDriver
typedef AZStd::unordered_set< SocketDriverAddress, SocketDriverAddress::HasherAddressSetType
 
- Public Types inherited from GridMate::SocketDriverCommon
using SocketType = Platform::SocketType_Platform
 
- Public Types inherited from GridMate::Driver
enum  ErrorCodes {
  EC_OK = 0, EC_SOCKET_CREATE, EC_SOCKET_LISTEN, EC_SOCKET_CLOSE,
  EC_SOCKET_MAKE_NONBLOCK, EC_SOCKET_BIND, EC_SOCKET_SOCK_OPT, EC_SOCKET_CONNECT,
  EC_SOCKET_ACCEPT, EC_SECURE_CONFIG, EC_SECURE_CREATE, EC_SECURE_CERT,
  EC_SECURE_PKEY, EC_SECURE_CA_CERT, EC_SEND, EC_SEND_ADDRESS_NOT_BOUND,
  EC_RECEIVE, EC_PLATFORM = 1000, EC_BUFFER_TOOLARGE = 1001
}
 
enum  BSDSocketFamilyType { BSD_AF_INET = 0, BSD_AF_INET6, BSD_AF_UNSPEC }
 
typedef unsigned int ResultCode
 

Public Member Functions

 GM_CLASS_ALLOCATOR (StreamSocketDriver)
 
 StreamSocketDriver (AZ::u32 maxConnections=32, AZ::u32 maxPacketSize=1024 *64, AZ::u32 inboundBufferSize=1024 *64, AZ::u32 outboundBufferSize=1024 *64)
 
void Update () override
 
AZ::u32 GetMaxNumConnections () const override
 Return maximum number of active connections at the same time. More...
 
AZ::u32 GetMaxSendSize () const override
 Return maximum data size we can send/receive at once in bytes, supported by the platform.
 
AZ::u32 GetPacketOverheadSize () const override
 Return packet overhead size in bytes.
 
ResultCode Initialize (AZ::s32 familyType=BSD_AF_INET, const char *address=nullptr, AZ::u32 port=0, bool isBroadcast=false, AZ::u32 receiveBufferSize=0, AZ::u32 sendBufferSize=0) override
 
AZ::u32 GetPort () const override
 Returns communication port (must be called after Initialize, otherwise it will return 0)
 
ResultCode Send (const AZStd::intrusive_ptr< DriverAddress > &to, const char *data, AZ::u32 dataSize) override
 
AZ::u32 Receive (char *data, AZ::u32 maxDataSize, AZStd::intrusive_ptr< DriverAddress > &from, ResultCode *resultCode=nullptr) override
 
ResultCode ConnectTo (const SocketDriverAddressPtr &addr)
 
ResultCode DisconnectFrom (const SocketDriverAddressPtr &addr)
 
ResultCode StartListen (AZ::s32 backlog)
 
ResultCode StopListen ()
 
AZ::u32 GetNumberOfConnections () const
 
bool IsConnectedTo (const SocketDriverAddressPtr &to) const
 
bool IsListening () const
 
- Public Member Functions inherited from GridMate::SocketDriver
 GM_CLASS_ALLOCATOR (SocketDriver)
 
 SocketDriver (bool isFullPackets, bool isCrossPlatform, bool isHighPerformance=false)
 
AZStd::intrusive_ptr< DriverAddressCreateDriverAddress (const AZStd::string &address) override
 
AZStd::intrusive_ptr< DriverAddressCreateDriverAddress (const sockaddr *addr) override
 Additional CreateDriverAddress function should be implemented.
 
void DestroyDriverAddress (DriverAddress *address) override
 Called only from the DriverAddress when the use count becomes 0.
 
- Public Member Functions inherited from GridMate::SocketDriverCommon
 SocketDriverCommon (bool isFullPackets=false, bool isCrossPlatform=false, bool isHighPerformance=false)
 
ResultCode Initialize (int familyType=BSD_AF_INET, const char *address=nullptr, unsigned int port=0, bool isBroadcast=false, unsigned int receiveBufferSize=0, unsigned int sendBufferSize=0) override
 
ResultCode Send (const AZStd::intrusive_ptr< DriverAddress > &to, const char *data, unsigned int dataSize) override
 Send data to a user defined address.
 
unsigned int Receive (char *data, unsigned int maxDataSize, AZStd::intrusive_ptr< DriverAddress > &from, ResultCode *resultCode=0) override
 
bool WaitForData (AZStd::chrono::microseconds timeOut=AZStd::chrono::microseconds(0)) override
 
void StopWaitForData () override
 
bool WasStopeedWaitingForData () override
 Return true if WaitForData was interrupted before the timeOut expired, otherwise false.
 
AZStd::string IPPortToAddress (const char *ip, unsigned int port) const override
 
bool AddressToIPPort (const AZStd::string &address, AZStd::string &ip, unsigned int &port) const override
 
- Public Member Functions inherited from GridMate::Driver
virtual void ProcessIncoming ()
 
virtual void ProcessOutgoing ()
 
virtual bool CanSend () const
 

Protected Types

enum  ConnectionState {
  TOP, ACCEPT, CONNECTING, CONNECT,
  ESTABLISHED, DISCONNECTED, IN_ERROR, MAX
}
 
using ConnectionMap = AZStd::unordered_map< SocketDriverAddressPtr, Connection *, SocketPtrHasher >
 
using ConnectionFactory = AZStd::function< Connection *(AZ::u32 inboundBufferSize, AZ::u32 outputBufferSize)>
 

Protected Member Functions

ResultCode SetSocketOptions (bool isBroadcast, AZ::u32 receiveBufferSize, AZ::u32 sendBufferSize) override
 
void CloseSocket ()
 
ResultCode PrepareSocket (AZ::u16 desiredPort, SocketAddressInfo &socketAddressInfo, SocketType &socket)
 
- Protected Member Functions inherited from GridMate::SocketDriverCommon
virtual SocketType CreateSocket (int af, int type, int protocol)
 returns result of socket(af,type,protocol)
 
virtual int BindSocket (const sockaddr *sockAddr, size_t sockAddrLen)
 returns the result of bind(sockAddr)
 
virtual ResultCode SetSocketOptions (bool isBroadcast, unsigned int receiveBufferSize, unsigned int sendBufferSize)
 set's default socket options
 

Protected Attributes

AZ::u32 m_maxConnections
 
AZ::u32 m_incomingBufferSize
 
AZ::u32 m_outgoingBufferSize
 
AZ::u32 m_maxPacketSize
 
AZ::u32 m_maxSendSize
 
AZ::u32 m_maxReceiveSize
 
bool m_isListening
 
AZStd::string m_boundAddress
 
BSDSocketFamilyType m_boundSocketFamily
 
ConnectionFactory m_connectionFactory
 
ConnectionMap m_connections
 
- Protected Attributes inherited from GridMate::SocketDriverCommon
SocketType m_socket
 
unsigned short m_port
 
bool m_isStoppedWaitForData
 True if last WaitForData was interrupted otherwise false.
 
bool m_isFullPackets
 True if we use max packet size vs internet safe packet size (64KB vs 1500 usually)
 
bool m_isCrossPlatform
 True if we support cross platform communication. Then we make sure we use common features.
 
bool m_isIpv6
 True if we use version 6 of the internet protocol, otherwise false.
 
bool m_isDatagram
 True if the socket was created with SOCK_DGRAM.
 
AZStd::unique_ptr< PlatformSocketDriverm_platformDriver
 Platform specific implementation of socket calls.
 
bool m_isHighPerformance
 True if using platform-specific high-performance implementation.
 
- Protected Attributes inherited from GridMate::Driver
bool m_canSend
 Can the driver accept more data.
 

Additional Inherited Members

- Static Public Member Functions inherited from GridMate::SocketDriverCommon
static AZStd::string IPPortToAddressString (const char *ip, unsigned int port)
 Create address for the socket driver from IP and port.
 
static bool AddressStringToIPPort (const AZStd::string &address, AZStd::string &ip, unsigned int &port)
 Decompose an address to IP and port.
 
static BSDSocketFamilyType AddressFamilyType (const AZStd::string &ip)
 Return the family type of the address (AF_INET,AF_INET6 AF_UNSPEC)
 
static BSDSocketFamilyType AddressFamilyType (const char *ip)
 
- Public Attributes inherited from GridMate::SocketDriver
AddressSetType m_addressMap
 

Detailed Description

Handles TCP socket streaming protocol

Member Function Documentation

◆ GetMaxNumConnections()

AZ::u32 GridMate::StreamSocketDriver::GetMaxNumConnections ( ) const
overridevirtual

Return maximum number of active connections at the same time.

Platform specific functionality.

Reimplemented from GridMate::SocketDriverCommon.


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