Skip to content

Instantly share code, notes, and snippets.

@mminer
Created July 21, 2020 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mminer/ed778252cf1e4004faaf7cc625fad1bc to your computer and use it in GitHub Desktop.
Save mminer/ed778252cf1e4004faaf7cc625fad1bc to your computer and use it in GitHub Desktop.
Unreal Engine utility function to get the host's IP address.
// Include "Sockets" in the `PrivateDependencyModuleNames` list in the Build.cs file.
#include "SocketSubsystem.h"
FString GetHost()
{
bool bCanBindAll;
return ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->GetLocalHostAddr(*GLog, bCanBindAll)->ToString(false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment