|
-
March 13th, 2009, 04:07 AM
#1
Sending Struct over UDP
I want to send a STRUCT over UDP using CAsyncSocket, based on a demo class I found called CUdpAsySk. Sending strings work nicely. Then creating a struct:
//struct defined in CUdpAsySk.h
struct StoSend
{
int16 version;
double gps_lat;
double gps_long;
}
class CUdpAsySk : public CAsyncSocket
{
public:
StoSend*pStoSend;
StoSend*pStoReceive;
...
}
//Send struct in void CUdpAsySk: oAsyncSendBuff()
m_strRemote="192.168.1.5";
m_nPort=4000;
dwBytes = SendTo((const char *)&pStoSend, sizeof(*pStoSend), m_nPort,m_strRemote);
//Receive
nRead = ReceiveFrom((char *)&pStoReceive, 699999, m_strRemote, m_nPort);
This work on local computer when bytes sent are equal or less then 20 bytes, from a remote computer no struct is received. When is failes I receive a:
Unhandled exception at 0x7c1772af (mfc71d.dll) in Device.exe: 0xC0000005: Access violation reading location 0x00000f94.
Anyone here that can help me with this problem?
Last edited by [email protected]; March 13th, 2009 at 04:10 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|