ISocketSubsystem

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

Windows
MacOS
Linux

Inheritance Hierarchy

ISocketSubsystem

FSteamSocketsSubsystem

References

Module

Sockets

Header

/Engine/Source/Runtime/Sockets/Public/SocketSubsystem.h

Include

#include "SocketSubsystem.h"

Syntax

class ISocketSubsystem

Remarks

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

Destructors

Name Description

Public function Virtual

~ISocketSubsystem()

Functions

Name Description

Public function

void

 

AddHostNameToCache

(
    const ANSICHAR* HostName,
    TSharedPtr< class FInternetAddr > A...
)

Stores the ip address with the matching host name

Public function

int32

 

BindNextPort

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

Bind to next available port.

Public function Virtual

TSharedRef< ...

 

CreateInternetAddr

(
    const FName ProtocolType
)

Create a FInternetAddr of the desired protocol

Public function

TSharedRef< ...

 

CreateInternetAddr()

Create a proper FInternetAddr representation

Public function Virtual

TUniquePtr< ...

 

CreateRecvMulti

(
    int32 MaxNumPackets,
    int32 MaxPacketSize,
    ERecvMultiFlags Flags
)

Create a platform specific FRecvMulti representation

Public function Virtual Const

FResolveInfo...

 

CreateResolveInfoCached

(
    TSharedPtr< FInternetAddr > Addr
)

Creates a resolve info cached struct to hold the resolved address

Public function

FSocket *...

 

CreateSocket

(
    const FName& SocketType,
    const FString& SocketDescription,
    const FName& ProtocolName
)

Creates a socket using the given protocol name.

Public function Virtual

FSocket *...

 

CreateSocket

(
    const FName& SocketType,
    const FString& SocketDescription,
    bool bForceUDP
)

Creates a socket

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

Public function

FUniqueSocke...

 

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.

Public function

FUniqueSocke...

 

CreateUniqueSocket

(
    const FName& SocketType,
    const FString& SocketDescription,
    bool bForceUDP
)

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.

Public function

void

 

DestroySocket

(
    FSocket* Socket
)

Cleans up a socket class

Public function Static

ISocketSubsy...

 

Get

(
    const FName& SubsystemName
)

Get the singleton socket subsystem for the given named subsystem

Public function

TSharedPtr< ...

 

GetAddressFromString

(
    const FString& InAddress
)

Serializes a string that only contains an address.

Public function

FAddressInfo...

 

GetAddressInfo

(
    const TCHAR* HostName,
    const TCHAR* ServiceName,
    EAddressInfoFlags QueryFlags,
    const FName ProtocolTypeName,
    ESocketType SocketType
)

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

Public function Virtual

void

 

GetAddressInfoAsync

(
    FAsyncGetAddressInfoCallback Callba...,
    const TCHAR* HostName,
    const TCHAR* ServiceName,
    EAddressInfoFlags QueryFlags,
    const FName ProtocolTypeName,
    ESocketType SocketType
)

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

Public function Virtual

FResolveInfo...

 

GetHostByName

(
    const ANSICHAR* HostName
)

Creates a platform specific async hostname resolution object

Public function

bool

 

GetHostByNameFromCache

(
    const ANSICHAR* HostName,
    TSharedPtr< class FInternetAddr >&...
)

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

Public function

bool

 

GetHostName

(
    FString& HostName
)

Determines the name of the local machine

Public function

ESocketError...

 

GetLastErrorCode()

Returns the last error that has happened

Public function Virtual

bool

 

GetLocalAdapterAddresses

(
    TArray< TSharedPtr< FInternetAddr >...
)

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

Public function Virtual

TSharedRef< ...

 

GetLocalBindAddr

(
    FOutputDevice& Out
)

Get a local IP to bind to.

Public function Virtual

TArray< TSha...

 

GetLocalBindAddresses()

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

Public function Virtual

TSharedRef< ...

 

GetLocalHostAddr

(
    FOutputDevice& Out,
    bool& bCanBindAll
)

Uses the platform specific look up to determine the host address

Public function Virtual

bool

 

GetMultihomeAddress

(
    TSharedRef< FInternetAddr >& Addr
)

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

Protected function Virtual Const

ESocketProto...

 

GetProtocolFamilyFromName

(
    const FName& InProtocolName
)

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

Protected function Virtual Const

FName

 

GetProtocolNameFromFamily

(
    ESocketProtocolFamily InProtocolFam...
)

Public function Const

const TCHAR ...

 

GetSocketAPIName()

Get the name of the socket subsystem

Public function

const TCHAR ...

 

GetSocketError

(
    ESocketErrors Code
)

Returns a human readable string from an error code

Public function

bool

 

HasNetworkDevice()

Public function

bool

 

Init

(
    FString& Error
)

Does per platform initialization of the sockets library

Public function Virtual Const

bool

 

IsRecvFromWithPktInfoSupported()

Returns true if FSocket::RecvFromWithPktInfo is supported by this socket subsystem.

Public function Virtual Const

bool

 

IsSocketRecvMultiSupported()

Returns true if FSocket::RecvMulti is supported by this socket subsystem

Public function Const

bool

 

IsSocketWaitSupported()

Returns true if FSocket::Wait is supported by this socket subsystem.

Public function

void

 

RemoveHostNameFromCache

(
    const ANSICHAR* HostName
)

Removes the host name to ip mapping from the cache

Public function

bool

 

RequiresChatDataBeSeparate()

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

Public function

bool

 

RequiresEncryptedPackets()

Some platforms require packets be encrypted.

Public function

void

 

Shutdown()

Performs platform specific socket clean up

Public function Static

void

 

ShutdownAllSystems()

Shutdown all registered subsystems

Public function

ESocketError...

 

TranslateErrorCode

(
    int32 Code
)

Translates the platform error code to a ESocketErrors enum

Public function Virtual

double

 

TranslatePacketTimestamp

(
    const FPacketTimestamp& Timestamp,
    ETimestampTranslation Translation
)

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

Deprecated Functions

Name Description

Public function Virtual

TSharedRef< ...

 

CreateInternetAddr

(
    uint32 Address,
    uint32 Port
)

To support different address sizes, use CreateInternetAddr with no arguments and call SetIp/SetRawIp and SetPort on the returned object

Public function Virtual

FSocket *...

 

CreateSocket

(
    const FName& SocketType,
    const FString& SocketDescription,
    ESocketProtocolFamily ProtocolType
)

Use the CreateSocket with the FName parameter for support for multiple protocol types.

Public function Virtual

FAddressInfo...

 

GetAddressInfo

(
    const TCHAR* HostName,
    const TCHAR* ServiceName,
    EAddressInfoFlags QueryFlags,
    ESocketProtocolFamily ProtocolType,
    ESocketType SocketType
)

Migrate to GetAddressInfo that takes an FName as the protocol specification.

Public function Virtual

ESocketError...

 

GetHostByName

(
    const ANSICHAR* HostName,
    FInternetAddr& OutAddr
)

Please use GetAddressInfo to query hostnames

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss