ISocketSubsystem

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

Windows
MacOS
Linux

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

TSharedRef< ...

 

CreateInternetAddr()

Create a proper FInternetAddr 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

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

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

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 local IP to bind to

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 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

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

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback