engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 成员函数 | Protected 成员函数 | 所有成员列表
ISocketSubsystem类 参考abstract

This is the base interface to abstract platform specific sockets API differences. 更多...

#include <SocketSubsystem.h>

Public 成员函数

void AddHostNameToCache (const ANSICHAR *HostName, TSharedPtr< class FInternetAddr > Addr)
 Stores the ip address with the matching host name 更多...
 
int32 BindNextPort (FSocket *Socket, FInternetAddr &Addr, int32 PortCount, int32 PortIncrement)
 Bind to next available port. 更多...
 
virtual TSharedRef< FInternetAddr > CreateInternetAddr ()=0
 Create a proper FInternetAddr representation
 
virtual TSharedRef< FInternetAddr > CreateInternetAddr (const FName ProtocolType)
 Create a FInternetAddr of the desired protocol
 
virtual TSharedRef< FInternetAddr > CreateInternetAddr (uint32 Address, uint32 Port=0)
 Create a proper FInternetAddr representation 更多...
 
virtual TUniquePtr< FRecvMulti > CreateRecvMulti (int32 MaxNumPackets, int32 MaxPacketSize, ERecvMultiFlags Flags=ERecvMultiFlags::None)
 Create a platform specific FRecvMulti representation 更多...
 
virtual class FResolveInfoCached * CreateResolveInfoCached (TSharedPtr< FInternetAddr > Addr) const
 Creates a resolve info cached struct to hold the resolved address 更多...
 
virtual FSocket * CreateSocket (const FName &SocketType, const FString &SocketDescription, bool bForceUDP=false)
 Creates a socket 更多...
 
virtual FSocket * CreateSocket (const FName &SocketType, const FString &SocketDescription, const FName &ProtocolName)=0
 Creates a socket using the given protocol name. 更多...
 
virtual FSocket * CreateSocket (const FName &SocketType, const FString &SocketDescription, ESocketProtocolFamily ProtocolType)
 Creates a socket 更多...
 
FUniqueSocket CreateUniqueSocket (const FName &SocketType, const FString &SocketDescription, bool bForceUDP=false)
 Creates a socket wrapped in a unique pointer that will call DestroySocket automatically - do not call it explicitly! This SocketSubsystem must also outlive the sockets it creates. 更多...
 
FUniqueSocket CreateUniqueSocket (const FName &SocketType, const FString &SocketDescription, const FName &ProtocolName)
 Creates a socket using the given protocol name, wrapped in a unique pointer that will call DestroySocket automatically - do not call it explicitly! This SocketSubsystem must also outlive the sockets it creates. 更多...
 
virtual void DestroySocket (FSocket *Socket)=0
 Cleans up a socket class 更多...
 
virtual TSharedPtr< FInternetAddr > GetAddressFromString (const FString &InAddress)=0
 Serializes a string that only contains an address. 更多...
 
virtual FAddressInfoResult GetAddressInfo (const TCHAR *HostName, const TCHAR *ServiceName=nullptr, EAddressInfoFlags QueryFlags=EAddressInfoFlags::Default, const FName ProtocolTypeName=NAME_None, ESocketType SocketType=ESocketType::SOCKTYPE_Unknown)=0
 Gets the address information of the given hostname and outputs it into an array of resolvable addresses. 更多...
 
virtual FAddressInfoResult GetAddressInfo (const TCHAR *HostName, const TCHAR *ServiceName=nullptr, EAddressInfoFlags QueryFlags=EAddressInfoFlags::Default, ESocketProtocolFamily ProtocolType=ESocketProtocolFamily::None, ESocketType SocketType=ESocketType::SOCKTYPE_Unknown)
 Gets the address information of the given hostname and outputs it into an array of resolvable addresses. 更多...
 
virtual void GetAddressInfoAsync (FAsyncGetAddressInfoCallback Callback, const TCHAR *HostName, const TCHAR *ServiceName=nullptr, EAddressInfoFlags QueryFlags=EAddressInfoFlags::Default, const FName ProtocolTypeName=NAME_None, ESocketType SocketType=ESocketType::SOCKTYPE_Unknown)
 Async variant of GetAddressInfo that fetches the data from the above function in an asynchronous task executed on an available background thread. 更多...
 
virtual class FResolveInfo * GetHostByName (const ANSICHAR *HostName)
 Creates a platform specific async hostname resolution object 更多...
 
virtual ESocketErrors GetHostByName (const ANSICHAR *HostName, FInternetAddr &OutAddr)
 Does a DNS look up of a host name This code assumes a lot, and as such, it's not guaranteed that the results provided by it are correct. 更多...
 
bool GetHostByNameFromCache (const ANSICHAR *HostName, TSharedPtr< class FInternetAddr > &Addr)
 Checks the host name cache for an existing entry (faster than resolving again) 更多...
 
virtual bool GetHostName (FString &HostName)=0
 Determines the name of the local machine 更多...
 
virtual ESocketErrors GetLastErrorCode ()=0
 Returns the last error that has happened
 
virtual bool GetLocalAdapterAddresses (TArray< TSharedPtr< FInternetAddr > > &OutAddresses)
 Gets the list of addresses associated with the adapters on the local computer. 更多...
 
virtual TSharedRef< FInternetAddr > GetLocalBindAddr (FOutputDevice &Out)
 Get a local IP to bind to. 更多...
 
virtual TArray< TSharedRef< FInternetAddr > > GetLocalBindAddresses ()
 Get bindable addresses that this machine can use as reported by GetAddressInfo with the BindableAddress flag. 更多...
 
virtual TSharedRef< FInternetAddr > GetLocalHostAddr (FOutputDevice &Out, bool &bCanBindAll)
 Uses the platform specific look up to determine the host address 更多...
 
virtual bool GetMultihomeAddress (TSharedRef< FInternetAddr > &Addr)
 Returns the multihome address if the flag is present and valid. 更多...
 
virtual const TCHAR * GetSocketAPIName () const =0
 Get the name of the socket subsystem 更多...
 
const TCHAR * GetSocketError (ESocketErrors Code=SE_GET_LAST_ERROR_CODE)
 Returns a human readable string from an error code 更多...
 
virtual bool HasNetworkDevice ()=0
 
virtual bool Init (FString &Error)=0
 Does per platform initialization of the sockets library 更多...
 
virtual bool IsSocketRecvMultiSupported () const
 Returns true if FSocket::RecvMulti is supported by this socket subsystem
 
virtual bool IsSocketWaitSupported () const =0
 Returns true if FSocket::Wait is supported by this socket subsystem.
 
void RemoveHostNameFromCache (const ANSICHAR *HostName)
 Removes the host name to ip mapping from the cache 更多...
 
virtual bool RequiresChatDataBeSeparate ()=0
 Some platforms require chat data (voice, text, etc.) to be placed into packets in a special way. 更多...
 
virtual bool RequiresEncryptedPackets ()=0
 Some platforms require packets be encrypted. 更多...
 
virtual void Shutdown ()=0
 Performs platform specific socket clean up
 
virtual ESocketErrors TranslateErrorCode (int32 Code)=0
 Translates the platform error code to a ESocketErrors enum
 
virtual double TranslatePacketTimestamp (const FPacketTimestamp &Timestamp, ETimestampTranslation Translation=ETimestampTranslation::LocalTimestamp)
 Converts a platform packet timestamp, into a local timestamp, or into a time delta etc. 更多...
 

静态 Public 成员函数

static ISocketSubsystem * Get (const FName &SubsystemName=NAME_None)
 Get the singleton socket subsystem for the given named subsystem
 
static void ShutdownAllSystems ()
 Shutdown all registered subsystems
 

Protected 成员函数

virtual ESocketProtocolFamily GetProtocolFamilyFromName (const FName &InProtocolName) const
 Conversion functions from the SocketProtocolFamily enum to the new FName system. 更多...
 

详细描述

This is the base interface to abstract platform specific sockets API differences.

成员函数说明

◆ AddHostNameToCache()

void ISocketSubsystem::AddHostNameToCache ( const ANSICHAR *  HostName,
TSharedPtr< class FInternetAddr >  Addr 
)

Stores the ip address with the matching host name

参数
HostNamethe host name to search for
Addrthe IP that will be copied from

◆ BindNextPort()

int32 ISocketSubsystem::BindNextPort ( FSocket *  Socket,
FInternetAddr &  Addr,
int32  PortCount,
int32  PortIncrement 
)

Bind to next available port.

参数
SocketThe socket that that will bind to the port
AddrThe local address and port that is being bound to (usually the result of GetLocalBindAddr()). This addresses port number will be modified in place
PortCountHow many ports to try
PortIncrementThe amount to increase the port number by on each attempt
返回
The bound port number, or 0 on failure

◆ CreateInternetAddr()

virtual TSharedRef< FInternetAddr > ISocketSubsystem::CreateInternetAddr ( uint32  Address,
uint32  Port = 0 
)
inlinevirtual

Create a proper FInternetAddr representation

参数
Addresshost address
Porthost port

◆ CreateRecvMulti()

virtual TUniquePtr< FRecvMulti > ISocketSubsystem::CreateRecvMulti ( int32  MaxNumPackets,
int32  MaxPacketSize,
ERecvMultiFlags  Flags = ERecvMultiFlags::None 
)
virtual

Create a platform specific FRecvMulti representation

参数
MaxNumPacketsThe maximum number of packet receives supported
MaxPacketSizeThe maximum supported packet size
FlagsFlags for specifying how FRecvMulti should be initialized (for e.g. retrieving timestamps)
返回
Returns the platform specific FRecvMulti instance

◆ CreateResolveInfoCached()

virtual class FResolveInfoCached * ISocketSubsystem::CreateResolveInfoCached ( TSharedPtr< FInternetAddr >  Addr) const
virtual

Creates a resolve info cached struct to hold the resolved address

@Param Addr address to resolve for the socket subsystem

返回
the new resolved address or NULL if failed

◆ CreateSocket() [1/3]

virtual FSocket * ISocketSubsystem::CreateSocket ( const FName &  SocketType,
const FString &  SocketDescription,
bool  bForceUDP = false 
)
inlinevirtual

Creates a socket

@Param SocketType type of socket to create (DGram, Stream, etc)

参数
SocketDescriptiondebug description
bForceUDPoverrides any platform specific protocol with UDP instead
返回
the new socket or NULL if failed

◆ CreateSocket() [2/3]

virtual FSocket * ISocketSubsystem::CreateSocket ( const FName &  SocketType,
const FString &  SocketDescription,
const FName &  ProtocolName 
)
pure virtual

Creates a socket using the given protocol name.

@Param SocketType type of socket to create (DGram, Stream, etc)

参数
SocketDescriptiondebug description
ProtocolNamethe name of the internet protocol to use for this socket. None should be handled.
返回
the new socket or NULL if failed

◆ CreateSocket() [3/3]

virtual FSocket * ISocketSubsystem::CreateSocket ( const FName &  SocketType,
const FString &  SocketDescription,
ESocketProtocolFamily  ProtocolType 
)
inlinevirtual

Creates a socket

@Param SocketType type of socket to create (DGram, Stream, etc)

参数
SocketDescriptiondebug description
ProtocolTypethe socket protocol to be used. Each subsystem must handle the None case and output a valid socket regardless.
返回
the new socket or NULL if failed

◆ CreateUniqueSocket() [1/2]

FUniqueSocket ISocketSubsystem::CreateUniqueSocket ( const FName &  SocketType,
const FString &  SocketDescription,
bool  bForceUDP = false 
)

Creates a socket wrapped in a unique pointer that will call DestroySocket automatically - do not call it explicitly! This SocketSubsystem must also outlive the sockets it creates.

@Param SocketType type of socket to create (DGram, Stream, etc)

参数
SocketDescriptiondebug description
bForceUDPoverrides any platform specific protocol with UDP instead
返回
the new socket or NULL if failed

◆ CreateUniqueSocket() [2/2]

FUniqueSocket ISocketSubsystem::CreateUniqueSocket ( const FName &  SocketType,
const FString &  SocketDescription,
const FName &  ProtocolName 
)

Creates a socket using the given protocol name, wrapped in a unique pointer that will call DestroySocket automatically - do not call it explicitly! This SocketSubsystem must also outlive the sockets it creates.

@Param SocketType type of socket to create (DGram, Stream, etc)

参数
SocketDescriptiondebug description
ProtocolNamethe name of the internet protocol to use for this socket. None should be handled.
返回
the new socket or NULL if failed

◆ DestroySocket()

virtual void ISocketSubsystem::DestroySocket ( FSocket *  Socket)
pure virtual

Cleans up a socket class

参数
Socketthe socket object to destroy

◆ GetAddressFromString()

virtual TSharedPtr< FInternetAddr > ISocketSubsystem::GetAddressFromString ( const FString &  InAddress)
pure virtual

Serializes a string that only contains an address.

This is a what you see is what you get, there is no DNS resolution of the input string, so only use this if you know you already have a valid address and will not need to convert. Otherwise, feed the address to GetAddressInfo for guaranteed results.

参数
InAddressthe address to serialize
返回
The FInternetAddr of the given string address. This will point to nullptr on failure.

◆ GetAddressInfo() [1/2]

virtual FAddressInfoResult ISocketSubsystem::GetAddressInfo ( const TCHAR *  HostName,
const TCHAR *  ServiceName = nullptr,
EAddressInfoFlags  QueryFlags = EAddressInfoFlags::Default,
const FName  ProtocolTypeName = NAME_None,
ESocketType  SocketType = ESocketType::SOCKTYPE_Unknown 
)
pure virtual

Gets the address information of the given hostname and outputs it into an array of resolvable addresses.

It is up to the caller to determine which one is valid for their environment.

This function allows for specifying FNames for the protocol type, allowing for support of other platform protocols

参数
HostNamestring version of the queryable hostname or ip address
ServiceNamestring version of a service name ("http") or a port number ("80")
QueryFlagsWhat flags are used in making the getaddrinfo call. Several flags can be used at once by bitwise OR-ing the flags together. Platforms are required to translate this value into a the correct flag representation.
ProtocolTypeNameUsed to limit results from the call. Specifying None will search all valid protocols. Callers will find they rarely have to specify this flag.
SocketTypeWhat socket type should the results be formatted for. This typically does not change any formatting results and can be safely left to the default value.
返回
the results structure containing the array of address results to this query

◆ GetAddressInfo() [2/2]

virtual FAddressInfoResult ISocketSubsystem::GetAddressInfo ( const TCHAR *  HostName,
const TCHAR *  ServiceName = nullptr,
EAddressInfoFlags  QueryFlags = EAddressInfoFlags::Default,
ESocketProtocolFamily  ProtocolType = ESocketProtocolFamily::None,
ESocketType  SocketType = ESocketType::SOCKTYPE_Unknown 
)
inlinevirtual

Gets the address information of the given hostname and outputs it into an array of resolvable addresses.

It is up to the caller to determine which one is valid for their environment.

参数
HostNamestring version of the queryable hostname or ip address
ServiceNamestring version of a service name ("http") or a port number ("80")
QueryFlagsWhat flags are used in making the getaddrinfo call. Several flags can be used at once by bitwise OR-ing the flags together. Platforms are required to translate this value into a the correct flag representation.
ProtocolTypeUsed to limit results from the call. Specifying None will search all valid protocols. Callers will find they rarely have to specify this flag.
SocketTypeWhat socket type should the results be formatted for. This typically does not change any formatting results and can be safely left to the default value.
返回
the results structure containing the array of address results to this query

◆ GetAddressInfoAsync()

virtual void ISocketSubsystem::GetAddressInfoAsync ( FAsyncGetAddressInfoCallback  Callback,
const TCHAR *  HostName,
const TCHAR *  ServiceName = nullptr,
EAddressInfoFlags  QueryFlags = EAddressInfoFlags::Default,
const FName  ProtocolTypeName = NAME_None,
ESocketType  SocketType = ESocketType::SOCKTYPE_Unknown 
)
virtual

Async variant of GetAddressInfo that fetches the data from the above function in an asynchronous task executed on an available background thread.

On Completion, this fires a callback function that will be executed on the same thread as the task's execution. The caller is responsible for either dispatching the result to the thread of their choosing or to allow the result callback execute on the task's thread.

This function allows for specifying FNames for the protocol type, allowing for support of other platform protocols

参数
Callbackthe callback function to fire when this query completes. Contains the FAddressInfoResult structure.
HostNamestring version of the queryable hostname or ip address
ServiceNamestring version of a service name ("http") or a port number ("80")
QueryFlagsWhat flags are used in making the getaddrinfo call. Several flags can be used at once by bitwise OR-ing the flags together. Platforms are required to translate this value into a the correct flag representation.
ProtocolTypeNameUsed to limit results from the call. Specifying None will search all valid protocols. Callers will find they rarely have to specify this flag.
SocketTypeWhat socket type should the results be formatted for. This typically does not change any formatting results and can be safely left to the default value.

◆ GetHostByName() [1/2]

virtual class FResolveInfo * ISocketSubsystem::GetHostByName ( const ANSICHAR *  HostName)
virtual

Creates a platform specific async hostname resolution object

参数
HostNamethe name of the host to look up
返回
the resolve info to query for the address

◆ GetHostByName() [2/2]

virtual ESocketErrors ISocketSubsystem::GetHostByName ( const ANSICHAR *  HostName,
FInternetAddr &  OutAddr 
)
inlinevirtual

Does a DNS look up of a host name This code assumes a lot, and as such, it's not guaranteed that the results provided by it are correct.

参数
HostNamethe name of the host to look up
Addrthe address to copy the IP address to

◆ GetHostByNameFromCache()

bool ISocketSubsystem::GetHostByNameFromCache ( const ANSICHAR *  HostName,
TSharedPtr< class FInternetAddr > &  Addr 
)

Checks the host name cache for an existing entry (faster than resolving again)

参数
HostNamethe host name to search for
Addrthe out param that the IP will be copied to
返回
true if the host was found, false otherwise

◆ GetHostName()

virtual bool ISocketSubsystem::GetHostName ( FString &  HostName)
pure virtual

Determines the name of the local machine

参数
HostNamethe string that receives the data
返回
true if successful, false otherwise

◆ GetLocalAdapterAddresses()

virtual bool ISocketSubsystem::GetLocalAdapterAddresses ( TArray< TSharedPtr< FInternetAddr > > &  OutAddresses)
virtual

Gets the list of addresses associated with the adapters on the local computer.

Unlike GetLocalHostAddr, this function does not give preferential treatment to multihome options in results. It's encouraged that users check for multihome before using the results of this function.

参数
OutAddresses- Will hold the address list.
返回
true on success, false otherwise.

◆ GetLocalBindAddr()

virtual TSharedRef< FInternetAddr > ISocketSubsystem::GetLocalBindAddr ( FOutputDevice &  Out)
virtual

Get a local IP to bind to.

Typically, it is better to use GetLocalBindAddresses as it better supports hybrid network functionality and less chances for connections to fail due to mismatched protocols.

◆ GetLocalBindAddresses()

virtual TArray< TSharedRef< FInternetAddr > > ISocketSubsystem::GetLocalBindAddresses ( )
virtual

Get bindable addresses that this machine can use as reported by GetAddressInfo with the BindableAddress flag.

This will return the various any address for usage. If multihome has been specified, only the multihome address will be returned in the array.

返回
If GetAddressInfo succeeded or multihome is specified, an array of addresses that can be binded on. Failure returns an empty array.

◆ GetLocalHostAddr()

virtual TSharedRef< FInternetAddr > ISocketSubsystem::GetLocalHostAddr ( FOutputDevice &  Out,
bool &  bCanBindAll 
)
virtual

Uses the platform specific look up to determine the host address

To better support multiple network interfaces and remove ambiguity between address protocols, it is encouraged to use GetLocalAdapterAddresses to determine machine addresses. Be sure to check GetMultihomeAddress ahead of time.

参数
Outthe output device to log messages to
bCanBindAlltrue if all can be bound (no primarynet), false otherwise
返回
The local host address

◆ GetMultihomeAddress()

virtual bool ISocketSubsystem::GetMultihomeAddress ( TSharedRef< FInternetAddr > &  Addr)
virtual

Returns the multihome address if the flag is present and valid.

For ease of use, this function will check validity of the address for the caller.

参数
Addrthe address structure which will have the Multihome address in it if set.
返回
If the multihome address was set and valid

◆ GetProtocolFamilyFromName()

virtual ESocketProtocolFamily ISocketSubsystem::GetProtocolFamilyFromName ( const FName &  InProtocolName) const
protectedvirtual

Conversion functions from the SocketProtocolFamily enum to the new FName system.

For now, both are supported, but it's better to use the FName when possible.

◆ GetSocketAPIName()

virtual const TCHAR * ISocketSubsystem::GetSocketAPIName ( ) const
pure virtual

Get the name of the socket subsystem

返回
a string naming this subsystem

◆ GetSocketError()

const TCHAR * ISocketSubsystem::GetSocketError ( ESocketErrors  Code = SE_GET_LAST_ERROR_CODE)

Returns a human readable string from an error code

参数
Codethe error code to check

◆ HasNetworkDevice()

virtual bool ISocketSubsystem::HasNetworkDevice ( )
pure virtual
返回
Whether the machine has a properly configured network device or not

◆ Init()

virtual bool ISocketSubsystem::Init ( FString &  Error)
pure virtual

Does per platform initialization of the sockets library

参数
Errora string that is filled with error information
返回
true if initialized ok, false otherwise

◆ RemoveHostNameFromCache()

void ISocketSubsystem::RemoveHostNameFromCache ( const ANSICHAR *  HostName)

Removes the host name to ip mapping from the cache

参数
HostNamethe host name to search for

◆ RequiresChatDataBeSeparate()

virtual bool ISocketSubsystem::RequiresChatDataBeSeparate ( )
pure virtual

Some platforms require chat data (voice, text, etc.) to be placed into packets in a special way.

This function tells the net connection whether this is required for this platform

◆ RequiresEncryptedPackets()

virtual bool ISocketSubsystem::RequiresEncryptedPackets ( )
pure virtual

Some platforms require packets be encrypted.

This function tells the net connection whether this is required for this platform

◆ TranslatePacketTimestamp()

virtual double ISocketSubsystem::TranslatePacketTimestamp ( const FPacketTimestamp &  Timestamp,
ETimestampTranslation  Translation = ETimestampTranslation::LocalTimestamp 
)
virtual

Converts a platform packet timestamp, into a local timestamp, or into a time delta etc.

参数
TimestampThe timestamp to translate
TranslationThe type of translation to perform on the timestamp (time delta is usually faster than local timestamp)
返回
Returns the translated timestamp or delta

该类的文档由以下文件生成: