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.
| void ISocketSubsystem::AddHostNameToCache | ( | const ANSICHAR * | HostName, |
| TSharedPtr< class FInternetAddr > | Addr | ||
| ) |
Stores the ip address with the matching host name
| HostName | the host name to search for |
| Addr | the IP that will be copied from |
| int32 ISocketSubsystem::BindNextPort | ( | FSocket * | Socket, |
| FInternetAddr & | Addr, | ||
| int32 | PortCount, | ||
| int32 | PortIncrement | ||
| ) |
Bind to next available port.
| Socket | The socket that that will bind to the port |
| Addr | The local address and port that is being bound to (usually the result of GetLocalBindAddr()). This addresses port number will be modified in place |
| PortCount | How many ports to try |
| PortIncrement | The amount to increase the port number by on each attempt |
|
inlinevirtual |
Create a proper FInternetAddr representation
| Address | host address |
| Port | host port |
|
virtual |
Create a platform specific FRecvMulti representation
| MaxNumPackets | The maximum number of packet receives supported |
| MaxPacketSize | The maximum supported packet size |
| Flags | Flags for specifying how FRecvMulti should be initialized (for e.g. retrieving timestamps) |
|
virtual |
Creates a resolve info cached struct to hold the resolved address
@Param Addr address to resolve for the socket subsystem
|
inlinevirtual |
Creates a socket
@Param SocketType type of socket to create (DGram, Stream, etc)
| SocketDescription | debug description |
| bForceUDP | overrides any platform specific protocol with UDP instead |
|
pure virtual |
Creates a socket using the given protocol name.
@Param SocketType type of socket to create (DGram, Stream, etc)
| SocketDescription | debug description |
| ProtocolName | the name of the internet protocol to use for this socket. None should be handled. |
|
inlinevirtual |
Creates a socket
@Param SocketType type of socket to create (DGram, Stream, etc)
| SocketDescription | debug description |
| ProtocolType | the socket protocol to be used. Each subsystem must handle the None case and output a valid socket regardless. |
| 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)
| SocketDescription | debug description |
| bForceUDP | overrides any platform specific protocol with UDP instead |
| 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)
| SocketDescription | debug description |
| ProtocolName | the name of the internet protocol to use for this socket. None should be handled. |
|
pure virtual |
Cleans up a socket class
| Socket | the socket object to destroy |
|
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.
| InAddress | the address to serialize |
|
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
| HostName | string version of the queryable hostname or ip address |
| ServiceName | string version of a service name ("http") or a port number ("80") |
| QueryFlags | What 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. |
| ProtocolTypeName | Used to limit results from the call. Specifying None will search all valid protocols. Callers will find they rarely have to specify this flag. |
| SocketType | What 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. |
|
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.
| HostName | string version of the queryable hostname or ip address |
| ServiceName | string version of a service name ("http") or a port number ("80") |
| QueryFlags | What 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. |
| ProtocolType | Used to limit results from the call. Specifying None will search all valid protocols. Callers will find they rarely have to specify this flag. |
| SocketType | What 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. |
|
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
| Callback | the callback function to fire when this query completes. Contains the FAddressInfoResult structure. |
| HostName | string version of the queryable hostname or ip address |
| ServiceName | string version of a service name ("http") or a port number ("80") |
| QueryFlags | What 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. |
| ProtocolTypeName | Used to limit results from the call. Specifying None will search all valid protocols. Callers will find they rarely have to specify this flag. |
| SocketType | What 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. |
|
virtual |
Creates a platform specific async hostname resolution object
| HostName | the name of the host to look up |
|
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.
| HostName | the name of the host to look up |
| Addr | the address to copy the IP address to |
| bool ISocketSubsystem::GetHostByNameFromCache | ( | const ANSICHAR * | HostName, |
| TSharedPtr< class FInternetAddr > & | Addr | ||
| ) |
Checks the host name cache for an existing entry (faster than resolving again)
| HostName | the host name to search for |
| Addr | the out param that the IP will be copied to |
|
pure virtual |
Determines the name of the local machine
| HostName | the string that receives the data |
|
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. |
|
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.
|
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.
|
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.
| Out | the output device to log messages to |
| bCanBindAll | true if all can be bound (no primarynet), false otherwise |
|
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.
| Addr | the address structure which will have the Multihome address in it if set. |
|
protectedvirtual |
|
pure virtual |
Get the name of the socket subsystem
| const TCHAR * ISocketSubsystem::GetSocketError | ( | ESocketErrors | Code = SE_GET_LAST_ERROR_CODE | ) |
Returns a human readable string from an error code
| Code | the error code to check |
|
pure virtual |
|
pure virtual |
Does per platform initialization of the sockets library
| Error | a string that is filled with error information |
| void ISocketSubsystem::RemoveHostNameFromCache | ( | const ANSICHAR * | HostName | ) |
Removes the host name to ip mapping from the cache
| HostName | the host name to search for |
|
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
|
pure virtual |
Some platforms require packets be encrypted.
This function tells the net connection whether this is required for this platform
|
virtual |
Converts a platform packet timestamp, into a local timestamp, or into a time delta etc.
| Timestamp | The timestamp to translate |
| Translation | The type of translation to perform on the timestamp (time delta is usually faster than local timestamp) |