I have been trying to receive a data packet from a client however during the recvfrom() process I think im doing something wrong…
I have whats named a DataPacket and its just a class with some x & y values
The Client does the following…
int UDPCon::Send(DataPacket dPacket)
{
int n = sendto(m_Socket, (char *)&dPacket, PACKETSIZE, 0, (struct sockaddr *)&m_RemoteAddress, m_SocketAddressSize);
return n;
}
And the server receives
int CUDPSocket::Receive(DataPacket *data)
{
int n = recvfrom(m_Socket, (char *) &data, PACKETSIZE, 0, (struct sockaddr *)&m_RemoteAddress, &m_SocketAddressSize);
return n;
}
This used to work when I was simply sending char’s without the casting back so the code did work. I think im doing something wrong with the pointer, as soon as the recvfrom() has put the data into “data” the DataPacket “data” becomes “expression cannot be evaluated”
I would really appreciate any help
Thanks
It seems you’re sending a struct, or at least the raw data in a
DataPacket. In that case, change the server code toThough, you should show the declaration of DataPacket and PACKETSIZE , the above might or might not do what you need to do.