I use version 4.4 preview.
and i saw lots of post about socket network.
i just want to make an echo client.
but it’s not working many problems…
i added Build.cs PublicDependencyModuleNames “Sockets”
then i include that cause when it doesn’t exist i have to see properties error
#include "Runtime/Networking/Public/Interfaces/IPv4/IPv4Address.h"
#include "Runtime/Networking/Public/Interfaces/IPv4/IPv4SubnetMask.h"
#include "Runtime/Sockets/Public/Sockets.h"
#include "Runtime/Sockets/Public/SocketSubsystem.h"
#include "Runtime/Networking/Public/Common/TcpListener.h"
#include "Runtime/Core/Public/Templates/SharedPointer.h"
and that’s my source codes
Aa019GameMode::Aa019GameMode(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
// set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/Blueprints/MyCharacter"));
if (PlayerPawnBPClass.Class != NULL)
{
DefaultPawnClass = PlayerPawnBPClass.Class;
}
FSocket* Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, TEXT("default"), false);
FString address = TEXT("127.0.0.1");
int32 port = 19834;
FIPv4Address ip;
FIPv4Address::Parse(address, ip);
TSharedRef addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
addr->SetIp(ip.GetValue());
addr->SetPort(port);
bool connected = Socket->Connect(*addr);
FString serialized = TEXT("loadPlayer|1");
TCHAR *serializedChar = serialized.GetCharArray().GetData();
int32 size = FCString::Strlen(serializedChar);
int32 sent = 0;
bool successful = Socket->Send((uint8*)TCHAR_TO_UTF8(serializedChar), size, sent);
}
it’s doesn’t compile
i need your help please.