Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Writing Data to a UDP socket error and stack error
Forum Updated to NodeBB v4.3 + New Features

Writing Data to a UDP socket error and stack error

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vezprog
    wrote on last edited by
    #1

    This is my configuration:

    @
    void IOProcessor::button()
    {
    char udpDataOut[2];
    // build byte array
    udpDataOut[0] = 0x23;
    udpDataOut[1] = 0x00;
    // send data
    flag = udpSocket.write(udpDataOut, 2);
    checkSendStatus(flag);
    }

    void checkSendStatus(int status)
    {
    if(status < 0){
    // display message box
    QMessageBox msgBox;
    msgBox.setText("Data was unable to be sent to IO Processor");
    msgBox.exec();
    }
    }
    @

    I do have a lot more going on in the app other than this, but this is just one occasion that I need to send data. I am getting a -1 returned every time when trying to send data. I am already receiving data constantly on the port which means I am connected. That is why I dont use readDatagram(). After clicking the button that triggers the udp send and closing out of the program, I get a stack error. This is AFTER I close the program in my console window.

    *** glibc detected *** /home/dvez/Desktop/CEI_QtApp-build-desktop/CEI_QtApp: free(): invalid pointer: 0x0000000000619650 ***
    ======= Backtrace: =========
    /lib/x86_64-linux-gnu/libc.so.6(+0x78a8f)[0x7f70a4be1a8f]
    /lib/x86_64-linux-gnu/libc.so.6(cfree+0x73)[0x7f70a4be58e3]
    /home/dvez/QtSDK/Desktop/Qt/473/gcc/lib/libQtCore.so.4(_ZN14QObjectPrivate14deleteChildrenEv+0x50)[0x7f70a5a590c0]
    /home/dvez/QtSDK/Desktop/Qt/473/gcc/lib/libQtGui.so.4(_ZN7QWidgetD2Ev+0x29b)[0x7f70a633ae9b]
    /home/dvez/Desktop/CEI_QtApp-build-desktop/CEI_QtApp[0x4067f3]
    /home/dvez/Desktop/CEI_QtApp-build-desktop/CEI_QtApp[0x404a7f]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xff)[0x7f70a4b87eff]
    /home/dvez/Desktop/CEI_QtApp-build-desktop/CEI_QtApp[0x404969]

    with a ton more mumbo jumbo that I am not really sure what it means. I have no experience with Qt and sending and receiving data. Although, I am receiving data correctly from my device, it just wont send. I am thinking its a memory issue with the fact I am not allocating memory for something I should be. But, I thought when you initialize a char[] pointer array, it allocates memory already. Or maybe I am not freeing it correctly? It could be possible that the memory is not being free'ed on the program close, yet that still doesn't explain why I am not able to send data correctly. The device has its own protocol and is currently working with a vb application using the same byte arrays shown below. So, I know that the device is working properly. Remember, this is a very large project, and this is 1 of 15 times I would like to send udpData Out the socket, and the program is constantly reading data from the socket.

    I can post more info on the issue if needed.

    Anyone have any ideas for what could be happening or enlighten me in the proper way to output data on the udp socket?

    Thanks in advance!

    Edit: Here is my close function as well
    @
    Connect::~Connect()
    {
    char udpDataOut[2];
    // build byte array
    udpDataOut[0] = 0x22; // 1st byte
    udpDataOut[1] = 0x00; // 2nd byte
    // send data
    flag = udpSocket.write(udpDataOut, 2);
    checkSendStatus(flag);

    // delete the ui and close the application
    delete ui;
    

    }
    @

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Could you show the class definition and the constructor? (or all the code, if you're at it, a zipped project is always good).

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved