After upgrading from 4.13 to 4.13.1, this always return nNetAddress as NULL:
TSharedRef nNetAddress = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
Can someone please help fix this?
Thx.
After upgrading from 4.13 to 4.13.1, this always return nNetAddress as NULL:
TSharedRef nNetAddress = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
Can someone please help fix this?
Thx.
Hey KillerPenguin,
I am not seeing the same issue. Here is what I have setup:
[GAME.Build.cs]
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Sockets", "Networking" });
[ISocketActor.h]
#pragma once
#include "GameFramework/Actor.h"
#include "ISocketActor.generated.h"
UCLASS()
class AH503580_API AISocketActor : public AActor
{
GENERATED_BODY()
public:
AISocketActor();
virtual void BeginPlay() override;
virtual void Tick( float DeltaSeconds ) override;
UFUNCTION( BlueprintCallable, Category = "Socket" )
void ConnectToHost( );
UFUNCTION( BlueprintCallable, Category = "Socket" )
void SendMessage( FString Message );
UPROPERTY( BlueprintReadOnly, Category = "Socket" )
bool bConnected;
class FSocket* Socket;
};
[ISocketActor.cpp]
#include "AH503580.h"
#include "ISocketActor.h"
#include "Networking.h"
#include "Runtime/Core/Public/Templates/SharedPointer.h"
AISocketActor::AISocketActor()
{
PrimaryActorTick.bCanEverTick = true;
}
void AISocketActor::BeginPlay()
{
Super::BeginPlay();
}
void AISocketActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
void AISocketActor::ConnectToHost( )
{
Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->
CreateSocket(NAME_Stream, TEXT("default"), false);
if( Socket )
{
FString address = TEXT("127.0.0.1");
int32 port = 444;
FIPv4Address ip;
FIPv4Address::Parse(address, ip);
TSharedRef<FInternetAddr> addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
addr->SetIp(ip.Value);
addr->SetPort(port);
bConnected = Socket->Connect(*addr);
}
}
void AISocketActor::SendMessage( FString Message )
{
if( bConnected )
{
TCHAR *serializedChar = Message.GetCharArray().GetData();
int32 size = FCString::Strlen(serializedChar);
int32 sent = 0;
Socket->Send((uint8*)TCHAR_TO_UTF8(serializedChar), size, sent);
}
}
I am then connecting to a local “server”, the code for that is here:
[WindowsMultiChatClient/Server at master · Vawx/WindowsMultiChatClient · GitHub][1]
Finally, this is what happens when I connect:
![)
Can you give me anymore information on your issue? Maybe I can help further.
Thanks.