Solved QUdpSocket : simple communication between 2 Qt applications
-
@LeLev
@dheerendra's code is the code to put into your client.
OIC, he wrote "server" --- it must have been a slip, he meant "client" :) -
That worked thank you very much
void skReady(){ QByteArray buffer; buffer.resize(static_cast<int>(sk->pendingDatagramSize())); QHostAddress sender("127.0.0.1"); quint16 senderPort=65111; qDebug()<<sk->readDatagram(buffer.data(), buffer.size(),&sender, &senderPort); }
-
Some confusion with where to place my code. Code has to be placed in App2(receiver) & not in the sender(App1)
- Client is writing data. So what you have in sender is fine.
- Receiver - You should place the code I suggested.
Then tell me.
-
@dheerendra
I'm only used to TCP. Never thought about terminology for UDP! I would have called the [UDP] server the side which is writing, not client, but maybe you know better than I :)
https://stackoverflow.com/questions/9951875/who-is-the-server-and-who-is-the-client-in-udp -
OK. Client & Server is only terminology.
- Server is the one which is waiting for connection.
- Client is the one which is initiating the connection.
Once connection is established client/server terminology w.r.t data transfer is blurred as both will start transferring the data.
-
@dheerendra i am using QT widget application to receive udp packets from another PC. my udp source is a labview VI. i am able to receive the data which i am sending .it is displaying in the debug window but not displaying in the user interface window.i tried textedit and listwidget. but not displaying anything. this is my first QT pgm. plz help.
-
@reshu
Raise a new topic for this (and you will need to show some code beyond what you have asked here before anyone can help you). It has nothing to do with thisQUdpSocket
issue. -
@JonB i am not able to find the link for a new topic
-
@reshu
So when you go to https://forum.qt.io/category/10/general-and-desktop you do not see a big blue New Topic button at the top of the page?You seemed to be able to raise https://forum.qt.io/topic/113963/udp-data-reception ?
-
@JonB yes