Can a QTcpSocket emit the disconnected signal without emitting an RemoteHostClosedError error?
-
My question is a very simple one. The title says it all. I have been thinking about this for some time now. From what i see when RemoteHostClosedError is emitted the socket is disconnected. Is it both ways? Can a socket disconnect without emitting any error at all? Do i have to handle both signals seperately (Disconnected then Error with RemoteHostClosedError) ?
-
@VRonin Thank you! I see calling disconnectFromHost doesnt trigger the RemoteHostClosedError. But is there any other use case where disconnected can be emitted without RemoteHostClosedError too? I am asking this because i want to know if i always have to handle both
-
@Kelvin-Royal said in Can a QTcpSocket emit the disconnected signal without emitting an RemoteHostClosedError error?:
Can a socket disconnect without emitting any error at all?
Surely. If you close the socket you'd get the
disconnected()
signal but this isn't really an error, is it?Do i have to handle both signals seperately (Disconnected then Error with RemoteHostClosedError) ?
The answer to this really depends on the situation, but as a rule of thumb I'd say yes.
PS.
Oh, I see I'm late to the party ... -
@kshegunov alright i will handle both then just to be on the safe side. so without calling disconnectFromHost, a socket cannot in anyway gracefully close itself without triggering the RemoteHostClosedError right? Is my assumption correct?
-
@Kelvin-Royal said in Can a QTcpSocket emit the disconnected signal without emitting an RemoteHostClosedError error?:
so without calling disconnectFromHost, a socket cannot in anyway gracefully close itself without triggering the RemoteHostClosedError right? Is my assumption correct?
I'd say yes, however
disconnectFromHost
might be called implicitly by Qt itself, e.g. if you delete the socket object directly. -
@kshegunov Alright. Now am ok! I understand QTcpSocket better. Thank you guys