QTcpSocket 'connected()' signal issue
Hello,
I wanted to do an action when an incoming connection to the server is established from a client.
i wrote this line :
Code:
connect(socket,SIGNAL(connected()), this, SLOT(connected()));
while "socket" is is a pointer to QTcpSocket :
But the statement doesn't invoke te SLOT "connected()" .
but when I write the following code:
Code:
connect(socket,SIGNAL(disconnected()), this, SLOT(connected()));
The SLOT "connected()" will be called when the Client is exited.
The issue:
I need to invoke the SLOT when an incoming connection established from a client.
Thanks.
Re: QTcpSocket 'connected()' signal issue
There is some inconsistency in your posting:
Quote:
Originally Posted by
Vladimir_
I wanted to do an action when an incoming connection to the server is established from a client.
This sounds like you are writing server code.
Quote:
Originally Posted by
Vladimir_
while "socket" is is a pointer to QTcpSocket :
while this is clearly client code.
For a client the connect should work, i.e. the slot should be invoked when the socket establishes a connection to the server.
For a server, the client is already connected (it has connected to the server after all), so the socket is already in "connection established" state.
Cheers,
_
Re: QTcpSocket 'connected()' signal issue
lol i was using a QTcpSocket in the server...
So what's the SIGNAL i have to make to get the incoming connection ?? "using QTcpServer"
thanx
Re: QTcpSocket 'connected()' signal issue
QTcpServer... the answer is in the first few sentences of the detailed description. Try the Fortune Server Example, also linked from the detailed description section, for a complete worked example.