Download

[Need help] struct over Fsocket

Hello to everyone, i’m new with unreal engine, i’m starting to make my login screen with blueprint etc, i made the basics c++ server by my self with windows socket.

Everything is working fine, i can access to my server with the FSocket, but at the moment to send my struct over the FSocket, but the value are not the good one, so i need some help to understand how the cast is supposed to do…

Struct proto:


struct Packet
{
	int i;
	std::string name;
};

Unreal FSocket send:


Packet a;
a.i = 11991;
a.name = "MyUserName";
Socket->Send((uint8*)TCHAR_TO_UTF8(&a), sizeof(Packet), sended);

server receive :


recv(cli->socket, (char*)&a, sizeof(Packet), 0);
std::cout << a.i << " " << a.name << std::endl;

85a2bbe59d991e634cd4982a5be1144be4f9fa18.png

9944034 is my a.i
209372064 is mu a.name.

If anyone could enlighten me, it would be appreciated, thanks !

PS: i’m sorry for my english i’m french :slight_smile:

I fixed it, i didn’t cast as i should the sender packet and receiver.

you can close :).