UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SocketSubsystemBSD.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
9#include "SocketSubsystem.h"
10#include "IPAddress.h"
11
12#if PLATFORM_HAS_BSD_SOCKETS || PLATFORM_HAS_BSD_IPV6_SOCKETS
13
14class FSocketBSD;
16
18
22class FSocketSubsystemBSD : public ISocketSubsystem
23{
24public:
35 virtual FName GetDefaultSocketProtocolFamily() const
36 {
38 }
39
40
41 // ISocketSubsystem interface
44
45 virtual class FSocket* CreateSocket(const FName& SocketType, const FString& SocketDescription, bool bForceUDP = false) override
46 {
47 return CreateSocket(SocketType, SocketDescription, GetDefaultSocketProtocolFamily());
48 }
49
50 virtual class FSocket* CreateSocket(const FName& SocketType, const FString& SocketDescription, const FName& ProtocolType) override;
51
52 virtual void DestroySocket( class FSocket* Socket ) override;
53
54 virtual FAddressInfoResult GetAddressInfo(const TCHAR* HostName, const TCHAR* ServiceName = nullptr,
57 ESocketType SocketType = ESocketType::SOCKTYPE_Unknown) override;
58
59 virtual TSharedPtr<FInternetAddr> GetAddressFromString(const FString& InAddress) override;
60
61 virtual bool GetMultihomeAddress(TSharedRef<FInternetAddr>& Addr) override;
62
63 virtual bool GetHostName(FString& HostName) override;
64 virtual ESocketErrors GetLastErrorCode() override;
65
66 virtual const TCHAR* GetSocketAPIName() const override;
67
68 virtual bool RequiresChatDataBeSeparate() override
69 {
70 return false;
71 }
72
73 virtual bool RequiresEncryptedPackets() override
74 {
75 return false;
76 }
77
78 virtual ESocketErrors TranslateErrorCode( int32 Code ) override;
79
80 virtual bool IsSocketWaitSupported() const override;
81
83
87 UE_DEPRECATED(4.23, "Switch to the FName version for scalable protocol support")
90
95
98
99
103 virtual ESocketType GetSocketType(int32 InSocketType) const;
104
108 virtual int32 GetAddressInfoHintFlag(EAddressInfoFlags InFlags) const;
109
115
119 virtual class FSocketBSD* InternalBSDSocketFactory( SOCKET Socket, ESocketType SocketType, const FString& SocketDescription, const FName& SocketProtocol);
120
124 UE_DEPRECATED(4.22, "To support multiple stack types, move to the constructor that allows for specifying the protocol stack to initialize the socket on.")
125 virtual class FSocketBSD* InternalBSDSocketFactory(SOCKET Socket, ESocketType SocketType, const FString& SocketDescription)
126 {
127 return InternalBSDSocketFactory(Socket, SocketType, SocketDescription, GetDefaultSocketProtocolFamily());
128 }
129
137
138 // allow BSD sockets to use this when creating new sockets from accept() etc
139 friend FSocketBSD;
140};
141
142#endif
EAddressInfoFlags
Definition AddressInfoTypes.h:12
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
ESocketErrors
Definition SocketErrors.h:9
int32 SOCKET
Definition SocketSubsystemBSDPrivate.h:47
ESocketProtocolFamily
Definition SocketTypes.h:16
ESocketType
Definition SocketTypes.h:33
@ SOCKTYPE_Unknown
Definition SocketTypes.h:35
Definition NameTypes.h:617
Definition OutputDevice.h:133
Definition Sockets.h:19
Definition SocketSubsystem.h:58
virtual SOCKETS_API bool GetMultihomeAddress(TSharedRef< FInternetAddr > &Addr)
Definition SocketSubsystem.cpp:454
virtual bool IsSocketWaitSupported() const =0
virtual SOCKETS_API TSharedRef< FInternetAddr > GetLocalHostAddr(FOutputDevice &Out, bool &bCanBindAll)
Definition SocketSubsystem.cpp:414
virtual TSharedPtr< FInternetAddr > GetAddressFromString(const FString &InAddress)=0
virtual FAddressInfoResult GetAddressInfo(const TCHAR *HostName, const TCHAR *ServiceName=nullptr, EAddressInfoFlags QueryFlags=EAddressInfoFlags::Default, ESocketProtocolFamily ProtocolType=ESocketProtocolFamily::None, ESocketType SocketType=ESocketType::SOCKTYPE_Unknown)
Definition SocketSubsystem.h:187
virtual const TCHAR * GetSocketAPIName() const =0
virtual FSocket * CreateSocket(const FName &SocketType, const FString &SocketDescription, bool bForceUDP=false)
Definition SocketSubsystem.h:98
virtual bool RequiresChatDataBeSeparate()=0
virtual ESocketErrors GetLastErrorCode()=0
virtual void DestroySocket(FSocket *Socket)=0
virtual bool GetHostName(FString &HostName)=0
virtual TSharedRef< FInternetAddr > CreateInternetAddr()=0
virtual ESocketErrors TranslateErrorCode(int32 Code)=0
virtual bool RequiresEncryptedPackets()=0
Definition IConsoleManager.h:1792
Definition SharedPointer.h:692
Definition SharedPointer.h:153
const FLazyName IPv4(TEXT("IPv4"))
Definition SocketTypes.h:27
Definition AddressInfoTypes.h:100