![]() |
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.
|
#include <SocketDriver.h>
Inherits GridMate::Driver.
Inherited by GridMate::SocketDriver.
Classes | |
class | PlatformSocketDriver |
Public Types | |
using | SocketType = Platform::SocketType_Platform |
![]() | |
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 | |
SocketDriverCommon (bool isFullPackets=false, bool isCrossPlatform=false, bool isHighPerformance=false) | |
unsigned int | GetMaxNumConnections () const override |
Return maximum number of active connections at the same time. More... | |
unsigned int | GetMaxSendSize () const override |
Return maximum data size we can send/receive at once in bytes, supported by the platform. | |
unsigned int | GetPacketOverheadSize () const override |
Return packet overhead size in bytes. | |
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 |
unsigned int | 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, 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::intrusive_ptr< DriverAddress > | CreateDriverAddress (const AZStd::string &address) override=0 |
virtual AZStd::intrusive_ptr< DriverAddress > | CreateDriverAddress (const sockaddr *sockAddr)=0 |
Additional CreateDriverAddress function should be implemented. | |
![]() | |
virtual void | Update () |
virtual void | ProcessIncoming () |
virtual void | ProcessOutgoing () |
virtual bool | CanSend () const |
Protected Member Functions | |
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 | |
![]() | |
virtual void | DestroyDriverAddress (DriverAddress *address)=0 |
Protected Attributes | |
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< PlatformSocketDriver > | m_platformDriver |
Platform specific implementation of socket calls. | |
bool | m_isHighPerformance |
True if using platform-specific high-performance implementation. | |
![]() | |
bool | m_canSend |
Can the driver accept more data. | |
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 |
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) |
Base common class for all SocketBased drivers, you can't NOT create an instance of the SocketDriverCommon use CreateSocketDriver function for a BSD socket driver.
|
overridepure virtual |
Creates internal driver address to be used for send/receive calls.
Implements GridMate::Driver.
Implemented in GridMate::SocketDriver.
|
inlineoverridevirtual |
Return maximum number of active connections at the same time.
Platform specific functionality.
Implements GridMate::Driver.
Reimplemented in GridMate::StreamSocketDriver.
|
overridevirtual |
User should implement create and bind a UDP socket. This socket will be used for all communications.
ft | family type, for the BSD socket it can be AFT_IPV4 or AFT_IPV6. |
address | when 0 it we will assume "any address". |
port | When left 0, we use implicit bind (assigned by the system). Otherwise provide a valid port number. |
isBroadcast | is valid for Ipv4 only (otherwise ignored). Sets the socket to support broadcasts. |
receiveBufferSize | socket receive buffer size in bytes, use 0 for default values. |
sendBufferSize | socket send buffer size, use 0 for default values. |
Implements GridMate::Driver.
|
inlineoverridevirtual |
Address conversion functionality. They MUST implemented thread safe. Generally this is not a problem since they just part local data. Create address from ip and port. If ip == NULL we will assign a broadcast address.
Implements GridMate::Driver.
|
overridevirtual |
Receives a datagram and stores the source address. maxDataSize must be >= than GetMaxSendSize(). Returns the num of of received bytes.
Implements GridMate::Driver.
|
overridevirtual |
When you enter wait for data mode, for many reasons you might want to stop wait for data. If you implement this function you need to make sure it's a thread safe function.
Implements GridMate::Driver.
|
overridevirtual |
Wait for data to be to the ready for receive. Time out is the maximum time to wait before this function returns. If left to default value it will be in blocking mode (wait until data is ready to be received).
Implements GridMate::Driver.