Download

Get Server Port

I could not find anything related to this.
When I start dedicated server, the server is listening on port 7777, next on 7778 etc.
So, how to get server port in UE4?

Hello,
It seems that you can’t do that in blueprints (yet ?..) but you can in c++. not sure about best solution. Different threads in forum and answerhub like

https://answers.unrealengine.com/questions/355235/get-port-in-game-when-launch-dedicated-server.html

seeems mainly that you have to use GetWorld()->GetAddressURL().

@Fen thanks for answer. Already saw that. However, I am mostly working in Blueprints.
Is there any way to expose it to BP, if no how to call that function in C++ so I can get data (server port)?

To create node, i can’t do more than give link with informations as i never did myself : Custom Blueprint Node Creation tutorial - Unreal Engine Forums

about the way to do in c++, first link has it in.

I can’t help you more with c++ sadly.

Suggestion: Have a chat with LowEntry… :slight_smile:

Suggestion: Have a chat with LowEntry… :wink:

H

#pragma once

#include “CoreMinimal.h”
#include “Kismet/BlueprintFunctionLibrary.h”
#include “GameFramework/GameMode.h”
#include “MyBlueprintFunctionLibrary.generated.h”

/**
*
/
UCLASS()
class ADVANCEDSOCIALSYSTEM_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY() public:
//GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintPure, Category = “Custom”, meta = (Keywords = “Port Number”))
static FString GetPortNumber(AGameModeBase
CurrentGameMode);

};

CPP
#include “MyBlueprintFunctionLibrary.h”
#include “GameFramework/GameModeBase.h”
#include “AdvancedSocialSystem.h”

FString UMyBlueprintFunctionLibrary::GetPortNumber(AGameModeBase* CurrentGameMode)
{
FString PortNumber;
PortNumber = FString::FromInt(CurrentGameMode->GetWorld()->URL.Port);
return PortNumber;
}

this shiet crashes from the gamemode module… i m lost