Set socket information
-
Hi Folks,
I have one UDP and one TCP socket that are instances of QTcpSocket and QUdpSocket classes. I need to copy the IP and the port information from the TCP socket into the UDP object, but I think that I cannot use the connectToHost() method because the UDP server still isn't represented. Does anybody have idea how can I do that?
Regards,
Norbert -
Hi,
I'm working on network communication.
My project is writing an app that connect with our system through wifi.
At Device end, we install a Wifi to UART to communicate with ARM MCU in our controller.
Right now, the app can receive sensor value sent from controller.
However, the app still doesnot send command to controller.
I tried with TCP and UDP.
Anyone has idea on how to send command to a MCU based system?
Hi Moravas,
When I used UDP, here is my code:
while (udpSocket->hasPendingDatagrams()) {
QByteArray datagram;
datagram.resize(udpSocket->pendingDatagramSize());QHostAddress sender; quint16 senderPort; udpSocket->readDatagram(datagram.data(),datagram.size(), &sender, &senderPort); }
As you can see, in readDatagram will return addr and port of the sender.
You can use it.