How to detect RST flag with QTcpSocket
I am currently working on a network program. We know that when the remote host disconnects from you, it might be a normal disconnection or a reset. If it is a reset, the RST flag in the TCP packet is set. I want to know how to judge whether a disconnection is a normal one or a reset (using QTcpSocket when disconnected() is emitted). Additionally, if I want to send a packet with RST flag set, what should I do? Emit abort()?
I want to know how to judge whether a disconnection is a normal one or a reset (using QTcpSocket when disconnected() is emitted)
I don't think that's possible with
Additionally, if I want to send a packet with RST flag set, what should I do?
Why should you want to do that in the first place?
abort()is not a signal and you don't emit signals from outside of the objects themselves, but yes, you call the
abort()method. It should do what you want.
@koahnig Thanks. So which exactly of the element in QAbstractSocket::SocketError represents reset?
You need to follow the links already in the post before. There you find explanations much better than I can briefly summarize. The reset flag is part of a lower layer in TCP/IP. As already lined out by @kshegunov what for do you require to that there has been exactly this flag sent?
I fear when you are using Qt wrappings for TCP comms, this might be completely out of your control, because issued by the lower level routines not part of Qt.
@koahnig Actually I am working on a TCP relay server. When server resets the connection, I have to reset the connection to the client, too.
OK, that is explaining your need. ;)
Sometimes "simple" users got stuck with some thoughts of their needs, but actually do not need those details.
I am not sure, if you will receive response from here. This is typically more user oriented.
The developer's email list might be better for such details.