PDA

View Full Version : Networking using QTcpSockets & QAbstractSocket::ConnectionRefusedError



mtrpoland
25th February 2008, 10:21
I am new to networking programming.
As far as I understand a few basic things, I imagine that if I want to use QTcpSocket objects on both (client & server) sides I have to bind&listen somehow one socket (server) and connect the second (client).

I don't want to use QTcpServer as I do not need server be able to serve more than one connection.

And now how to execute bind&listen operation using QTcpSocket methods?

I tried to connectToHost(Qt::LocalHost,port); but no matter what port I choose I receive QAbstractSocket::ConnectionRefusedError...

I will be grateful for some hints. Dare show me my mistakes if I simply don't understand well the mechanism.

Regards

marcel
25th February 2008, 10:36
A server must bind/listen/accept.
A client must only connect(in this case using connectToHost).

So you get the error because no one is listening on the other end.