UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SocketSubsystemBSDPrivate.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"
6#include "SocketSubsystem.h"
7
8#if PLATFORM_HAS_BSD_SOCKET_FEATURE_WINSOCKETS
10
11 #include <winsock2.h>
12 #include <ws2tcpip.h>
13
14 typedef int32 SOCKLEN;
15
17#else
18#ifdef UE_SOCKET_API_WRAPPER
19 #include UE_SOCKET_API_WRAPPER
20#else
21 #include <unistd.h>
22 #include <sys/socket.h>
23#if PLATFORM_HAS_BSD_SOCKET_FEATURE_IOCTL
24 #include <fcntl.h>
25 #include <sys/types.h>
26 #include <sys/ioctl.h>
27#endif
28#if PLATFORM_HAS_BSD_SOCKET_FEATURE_POLL
29 #include <poll.h>
30#endif
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
33#if PLATFORM_HAS_BSD_SOCKET_FEATURE_GETHOSTNAME
34 #include <netdb.h>
35#endif
36#if PLATFORM_HAS_BSD_SOCKET_FEATURE_NODELAY
37 #include <netinet/tcp.h>
38#endif
39
40 #define ioctlsocket ioctl
41#endif
42
43 #define SOCKET_ERROR -1
44 #define INVALID_SOCKET -1
45
47 typedef int32 SOCKET;
49 typedef struct timeval TIMEVAL;
50
51 inline int32 closesocket(SOCKET Socket)
52 {
53 shutdown(Socket, SHUT_RDWR); // gracefully shutdown if connected
54 return close(Socket);
55 }
56
57#endif
58
59// Since the flag constants may have different values per-platform, translate into corresponding system constants.
60// For example, MSG_WAITALL is 0x8 on Windows, but 0x100 on other platforms.
62{
63 int TranslatedFlags = 0;
64
66 {
68#if PLATFORM_HAS_BSD_SOCKET_FEATURE_MSG_DONTWAIT
70#endif // PLATFORM_HAS_BSD_SOCKET_FEATURE_MSG_DONTWAIT
71 }
72
74 {
76 }
77
78 return TranslatedFlags;
79}
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
int TranslateFlags(ESocketReceiveFlags::Type Flags)
Definition SocketSubsystemBSDPrivate.h:61
struct timeval TIMEVAL
Definition SocketSubsystemBSDPrivate.h:49
sockaddr_in SOCKADDR_IN
Definition SocketSubsystemBSDPrivate.h:48
int32 SOCKET
Definition SocketSubsystemBSDPrivate.h:47
int32 closesocket(SOCKET Socket)
Definition SocketSubsystemBSDPrivate.h:51
socklen_t SOCKLEN
Definition SocketSubsystemBSDPrivate.h:46
Type
Definition SocketTypes.h:58
@ Peek
Definition SocketTypes.h:68
@ WaitAll
Definition SocketTypes.h:74