![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <SocketSubsystem.h>
Static Public Member Functions | |
| static SOCKETS_API ISocketSubsystem * | Get (const FName &SubsystemName=NAME_None) |
| static SOCKETS_API void | ShutdownAllSystems () |
Protected Member Functions | |
| virtual SOCKETS_API ESocketProtocolFamily | GetProtocolFamilyFromName (const FName &InProtocolName) const |
| virtual SOCKETS_API FName | GetProtocolNameFromFamily (ESocketProtocolFamily InProtocolFamily) const |
This is the base interface to abstract platform specific sockets API differences.
|
default |
|
virtualdefault |
| 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 |
|
pure virtual |
Create a proper FInternetAddr representation
|
inlinevirtual |
Create a FInternetAddr of the desired protocol
|
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. |
Cleans up a socket class
| Socket | the socket object to destroy |
|
static |
Get the singleton socket subsystem for the given named subsystem
|
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 |
Determines the name of the local machine
| HostName | the string that receives the data |
|
pure virtual |
Returns the last error that has happened
|
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 |
|
protectedvirtual |
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 |
Does per platform initialization of the sockets library
| Error | a string that is filled with error information |
|
virtual |
Returns true if FSocket::RecvFromWithPktInfo is supported by this socket subsystem.
|
virtual |
Returns true if FSocket::RecvMulti is supported by this socket subsystem
Returns true if FSocket::Wait is supported by this socket subsystem.
Removes the host name to ip mapping from the cache
| HostName | the host name to search for |
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
Some platforms require packets be encrypted. This function tells the net connection whether this is required for this platform
|
static |
Shutdown all registered subsystems
|
pure virtual |
Translates the platform error code to a ESocketErrors enum
|
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) |