Review Request 127501: Improve TCPSlaveBase::isConnected

David Faure faure at kde.org
Sun Mar 27 10:03:36 UTC 2016


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/127501/#review94042
-----------------------------------------------------------



Given how the socket API works, you should only call error() after a call that returns false (e.g. waitForConnected, etc.). As you found out, calling error() at random points in time doesn't give useful information, you get the last error that was ever set, even after 10 successful calls following the call that had an error.

Calling setError ourselves is a workaround, which doesn't fit with the Qt socket API (there is no "No error" error code).
UnknownSocketError *means* error, it doesn't mean no error.

It seems to me (from the description, I didn't read the code attentively) that the right solution is to actually disconnect after a RemoteHostClosedError. Then the state won't be ConnectedState anymore, and isConnected() will work as intended :-)

- David Faure


On March 26, 2016, 5:29 p.m., Albert Astals Cid wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/127501/
> -----------------------------------------------------------
> 
> (Updated March 26, 2016, 5:29 p.m.)
> 
> 
> Review request for KDE Frameworks.
> 
> 
> Repository: kio
> 
> 
> Description
> -------
> 
> Qt sockets returns ConnectedState even when error is set to RemoteHostClosedError after a write operation.
> 
> So make ::isConnected also check for RemoteHostClosedError.
> 
> This has the consequence that we have to create/delete the socket since Qt sockets have no way to reset their error state so if we want to reuse the slave to connect again it will never work with the same socket since it will always say RemoteHostClosedError.
> 
> I need this for https://git.reviewboard.kde.org/r/127502/
> 
> 
> Diffs
> -----
> 
>   src/core/tcpslavebase.cpp b9be69d 
> 
> Diff: https://git.reviewboard.kde.org/r/127501/diff/
> 
> 
> Testing
> -------
> 
> Seesms to work fine and the pop3 bugfix i have also works fine.
> 
> 
> Thanks,
> 
> Albert Astals Cid
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20160327/8292e4f5/attachment.html>


More information about the Kde-frameworks-devel mailing list