Hello
I’m making an application with an UDP client/server communication.
The client has to open the 3301 port on his router to receive the socket. (and the server has to open the 3300, but that is not importante)
And I would like to know how I could receive the socket on the PC's client without this opening port.
Server Side :
-Listening
connect(m_udpSocket, SIGNAL(readyRead()), this, SLOT(get()));
m_udpSocket = new QUdpSocket;
m_udpSocket->bind(QHostAddress::Any, 3300, QUdpSocket::ShareAddress);
connect(m_udpSocket, SIGNAL(readyRead()), this, SLOT(get()));
To copy to clipboard, switch view to plain text mode
-Sending
udpSocket.bind(3301); // I don't know if that is important
udpSocket.writeDatagram(datagram, ip, 3301);
QUdpSocket udpSocket;
udpSocket.bind(3301); // I don't know if that is important
udpSocket.writeDatagram(datagram, ip, 3301);
To copy to clipboard, switch view to plain text mode
Client Side :
-Listening
m_udpSocket
->bind
(QHostAddress::Any,
3301,
QUdpSocket::ShareAddress);
/// if I put *m_serverAdress instead of QHostAddress::Any, I receive nothing even with the port openningconnect(m_udpSocket, SIGNAL(readyRead()), this, SLOT(get()));
m_serverAdress = new QHostAddress("**.**.***.**");
m_udpSocket = new QUdpSocket;
m_udpSocket->bind(QHostAddress::Any, 3301, QUdpSocket::ShareAddress); /// if I put *m_serverAdress instead of QHostAddress::Any, I receive nothing even with the port openning
connect(m_udpSocket, SIGNAL(readyRead()), this, SLOT(get()));
To copy to clipboard, switch view to plain text mode
-Sending
m_udpSocket->writeDatagram(datagram, *m_serverAdress, 3300);
m_udpSocket->writeDatagram(datagram, *m_serverAdress, 3300);
To copy to clipboard, switch view to plain text mode
Thanks You
Bookmarks