Creating BP nodes, TSharedRef not working??

Ok, I do not want to use steam for ‘master server’ stuff. So I wrote a little test server that just takes a tcp connection using sockets. On the other end (in UE4) I wanted to make a BP node that allows you to connect to that server (to start with)…

So I have the following code in my project:

#include "BP_MPMENU_FPS_C.h"
#include "MyBlueprintFunctionLibrary.h"
#include "Sockets.h"
#include "Networking.h"
#include "SocketSubsystem.h"
//#include "SharedPointer.h"

UMyBlueprintFunctionLibrary::UMyBlueprintFunctionLibrary(const class FObjectInitializer& PCIP)
	: Super(PCIP){}

FString UMyBlueprintFunctionLibrary::RegisterHost()
	FSocket* Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(TEXT("default"), TEXT("default"), false);

	FString address = TEXT("");
	int32 port = 6666;
	FIPv4Address ip;
	FIPv4Address::Parse(address, ip);

	TSharedRef addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();

	bool connected = Socket->Connect(*addr);

	return FString("myBPlibrary is working!");

Just as a start to try to use a bp node to run the C++ to create the socket and connect…

Problem is I get “‘TSharedRef’ : use of class template requires template argument list” and other errrors related to TSharedRef not being properly recognized/initialized.

Have searched and find all examples do as my code above (or seem to), so not sure what I am missing. The above code is based on:

Any ideas where I have gone wrong or what I am missing? Thanks.

I managed to figure out the line needed to be:

TSharedRef<FInternetAddr> addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();

So now it builds without error.

However I set up a widget with a button, that when clicked calls this BP node, then prints out the return string just to make sure it is going all the way through the code. It crashed first time running it. It seems the

bool connected = Socket->Connect(*addr);

Causes the crash/lockup. I commented it out, and it all works fine, or at least comes out with the printed string, so nothing crashed.

Any ideas?

I should add the whole idea here is to build a little ‘master server’ that a host connects to, registers itself it it does not already exist, provides maxplayers, numplayers, and other such data, and the master server checks for a heartbeat to make sure host is alive. Then clients can query the master server for a list of active servers (sort of a replacement for ‘findsessions’ if mode is not set to LAN …

If anyone has any experience with such things or wants to help out, it would be appreciated. Plan to just build a basic system for all to use that do not want to deal with Steam for whatever reason.