I've seen few threads about my question, but, still I can't seem to solve the problem, and the replies are not sufficient. So here is the task: I have 2 PCs. One must transmit 100 udp packets, with a simple test data, and the other machine must read the datagrams. My code is as follows:
The server:
m_socket.udp = new QUdpSocket(this);
if (m_socket.udp->bind(QHostAddress("192.168.32.154"), 1234)) {
m_socket.udp->connectToHost(QHostAddress("192.168.32.154"), 1234);
m_socket.udp->waitForConnected();
}
connect(m_socket.udp, SIGNAL(connected()),
this, SLOT(handleConnection()));
connect(m_socket.udp, SIGNAL(readyRead()),
this, SLOT(readyReadUdp()));
So... first - the binding to IP of machine 1 fails. I must not specify it's IP.
The client is simple:
p_socket = new QUdpSocket(this);
p_socket->connectToHost(QHostAddress("192.168.32.94"), 1234);
connect(p_socket, SIGNAL(connected()), this, SLOT(writeDgram()));
....
void writeDgram() {
p_socket->write(QByteArray("test"));
}
So client code, as viewed in wireshark, comes to my server machine. But my server Qt code fails me. Any help here?
Yet, no one proposed that I can be firewalled. That was the problem. Removing the firewall solved this.