Results 1 to 2 of 2

Thread: bad UDP socket :(

  1. #1
    Join Date
    Nov 2006
    Posts
    41
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default bad UDP socket :(

    Hi, im trying to send/receive datagrams locally like this...
    For the sender
    Qt Code:
    1. udpSocket->connectToHost(leHost->text(), lePort->text().toUInt());
    2. QByteArray datagram = "//SearchingPlayers";
    3. qDebug() << "sent :: " << udpSocket->write(datagram);
    To copy to clipboard, switch view to plain text mode 
    Here i get 18 in console, then for the receiver...
    Qt Code:
    1. QHostAddress *remoteHost = new QHostAddress;
    2. while( udpSocket->hasPendingDatagrams() ){
    3. QByteArray datagram;
    4. datagram.resize(udpSocket->pendingDatagramSize());
    5. datagram = udpSocket->read(datagram.size());
    6. qDebug() << "received :: " << datagram.data();
    7. }
    To copy to clipboard, switch view to plain text mode 
    And it just freezes before qDebug(), each code is in different functions
    Im using localhost in leHost and port the port i bind in udpSocket->bind(45454); before in the constructor
    any ideas? thanks

  2. #2
    Join Date
    Nov 2006
    Posts
    41
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: bad UDP socket :(

    well i got it, i have to bind both apps before sending anything

Similar Threads

  1. Can any One help me? - Socket Programming?
    By vinod in forum Qt Programming
    Replies: 6
    Last Post: 18th November 2009, 09:46
  2. Replies: 4
    Last Post: 10th November 2006, 15:38
  3. How to write on a socket in another thread?
    By Valheru in forum Qt Programming
    Replies: 7
    Last Post: 12th October 2006, 10:52
  4. qt socket question
    By bluesguy82 in forum Qt Programming
    Replies: 4
    Last Post: 29th August 2006, 15:42
  5. Reading from TCP Socket crashes program
    By OnionRingOfDoom in forum Qt Programming
    Replies: 26
    Last Post: 27th January 2006, 19:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.