CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Sep 2008
    Posts
    4

    Arrow 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
  •  





Click Here to Expand Forum to Full Width

Featured