Hey, I’m trying to receive data from from my login server.
virtual bool Recv
(
uint8 * Data,
int32 BufferSize,
int32 & BytesRead,
ESocketReceiveFlags::Type Flags
)
My implementation goes…
uint8 Data;
BYTE BufferSize;
int32 BytesRead;
bool sent = Socket->Recv(Data, BufferSize, BytesRead);
Can someone assist me please to where I have went wrong.
I just want to receive data please.
Edit: To show implementation
The following is server code, so once the client connects it will send a welcome banner to the client. It’s more of a testing to see if I can receive data from the server.
NetworkStream ns = client.GetStream();
connections++;
Console.WriteLine("New client accepted: {0} active connections", connections);
byte[] daata = new byte[1024];
string welcome = "Welcome";
ns.Write(Encoding.ASCII.GetBytes(welcome), 0, welcome.Length);
ns.Flush();
//this is the C++ client code
Now after this is executed the client disconnects from the server, which I don’t understand, because the socket is streaming connecting orientated.
uint8 Data[1024]; //buffer size
int32 byteCount = 0; //the number os bytes read
int32 dataSize = 0; //the size of the data
Socket->Recv(Data, dataSize, byteCount);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(byteCount));
if (byteCount >= dataSize)
Socket->Recv(Data, byteCount, dataSize);
//ToDO: capture the message, if true then connect to master server and open game lobby level
P.S - is there any further reading you can recommend?