Socket Connection Issues
-
Hi,
I am having issues with connecting the @QUdpSocket @ signal with my host class' slot:
@connect(socket, SIGNAL(readyRead()), this, SLOT(readDatagram()));@Am I doing something wrong? I kinda tried this after the example...
Thanks!
-Maosug
-
Did you use "socket->connectToHost([TransmitServer], [Port]);" ? Then, signal will be emitted when the server is preparing for sending data.
-
[quote author="masoug" date="1294287656"]Hi,
I am having issues with connecting the @QUdpSocket @ signal with my host class' slot:
@connect(socket, SIGNAL(readyRead()), this, SLOT(readDatagram()));@Am I doing something wrong? I kinda tried this after the example...
Thanks!
-Maosug[/quote]
is socket a pointer or an object? if its an object, it must be
@connect(&socket, SIGNAL(readyRead()), this, SLOT(readDatagram()));@
-
[quote author="masoug" date="1294287656"]Hi,
I am having issues with connecting the @QUdpSocket @ signal with my host class' slot:
@connect(socket, SIGNAL(readyRead()), this, SLOT(readDatagram()));@Am I doing something wrong? I kinda tried this after the example...
Thanks!
-Maosug[/quote]
Sorry, no crystal ball here. Could you be a bit more specific on the issues you have?
-
Thanks for the quick replies.
Um, I probably should've given more context...
I have a server using Berkeley Sockets and it streams data on a specific port. Then I have a Qt GUI at the client end that connects to this server and receive/read datagrams from the server.
I created QUdpSocket as a pointer, so if I use &socket the compiler complains about the argument type incompatibility.
bq. Did you use “socket->connectToHost([TransmitServer], [Port]);” ? Then, signal will be emitted when the server is preparing for sending data.
I haven't used that method for connection. The connect function is returning false, so I think the problem has something to do with the object types...
Umm, did anyone else run into problems similar to this?
Thanks
-Masoug
-
You must call
@
udpSocket->bind(address, port);
@See "QUdpSockets":http://doc.qt.nokia.com/stable/qudpsocket.html#details docs and the complete example there.
-
Um, I did call bind() before connecting the socket...
-
For some further investigation we should better have a complete test program that shows the faulty behavior.
-
Hmmm, I will take a closer look at this. Thanks!