Hi,
Is there a way to send a string to a remote server using UE4’s FSocket tools?
I followed Rama’s code, while it’s great for receiving data the information that it had on the different ways of sending data was limited.
While on the topic, can someone give a clear distinction between 8bit Arrays and strings? Afaik an 8bit array is an array of characters, with each character being 8bit. So if a string is also essentially an array of characters, what’s the difference?
Anyways, here’s the snippet from rama’s tutorial here
// String from binary array
FString AMyActor::StringFromBinaryArray(TArray<uint8> BinaryArray)
{
BinaryArray.Add(0);
return FString(ANSI_TO_TCHAR(reinterpret_cast<const char*>(BinaryArray.GetData())));
}
and here is a snippet that I’ve worked on to tackle the problem more directly… again, the server I’m communicating with only accepts strings but unreal’s FSocket tools can only send uint8*. Is there any way around this?
// Sending a message to the server
FString VarFetch = "--My string goes here--";
TCHAR *VarFetchChar = VarFetch.GetCharArray().GetData();
int32 size = FCString::Strlen(VarFetchChar);
int32 sent = 0;
bool successful = Socket->Send((uint8*)TCHAR_TO_ANSI(VarFetchChar), size, sent);
Thanks!