[SOLVED] QUDPSocket Help
All I am trying to learn QUDPSocket and attempting to write an application to push data back and forth across a network between laptops. Nothing fancy just messages, but I want to send a msg from one system and catch it on the other. I found a nice example on line and it works but it seems to write and read the datagrams on the same system. So I have tried to bind the IPs of the two systems and I get nothing. I am sure I am missing something. Here is my code.
MyUDP::MyUDP(QObject *parent) : QObject(parent)
socket = new QUdpSocket(this); socket->connectToHost(QHostAddress(“126.96.36.199”), 1234, QIODevice::ReadWrite); connect(socket, SIGNAL), this, SLOT));
socket->writeDatagram(data, QHostAddress::LocalHost, 1234);
//this writes and reads fine.
void MyUDP::WriteData(QByteArray inMessage)
socket->writeDatagram(inMessage, QHostAddress(“188.8.131.52”), 1234);
Buffer.resize(socket->pendingDatagramSize()); //Pending DatagramSize is size of incoming data
socket->readDatagram(Buffer.data(), Buffer.size(), &sender, &senderPort);
//Process packets here.
qDebug() << “Message from : “ << sender.toString();
qDebug() << “Message Port : “ << senderPort;
qDebug() << “Message : “ << Buffer;
Sorry the code is postings strange. I tried to edit it several times.
Can you check the network setup ? Can you check whether client box and server box in same network ? Do you have reachability to both boxes ?Are they in same network ?Can you ping each IP address from each box ?
Yes I have pinged from both machines and they are on the same network. Once is connected through a wireless connection if that makes a difference, but I can still ping it.
Difficult to see your code. I can send you the working code. Can you drop email to me ?
No problem what is your email?
Just dropped an in mail for you. You can drop me an email.
I sent you a message with my email. Let me know if you received it.
I solved the issue. The server has to be set to LocalHost. then the client connects with the IP address. Everything seems to be listening properly.
I just sent another email