<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/127501/">https://git.reviewboard.kde.org/r/127501/</a>
     </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On March 27th, 2016, 10:03 a.m. UTC, <b>David Faure</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">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.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Calling setError ourselves is a workaround, which doesn't fit with the Qt socket API (there is no "No error" error code).
UnknownSocketError <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">means</em> error, it doesn't mean no error.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">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 :-)</p></pre>
 </blockquote>




 <p>On March 27th, 2016, 10:43 a.m. UTC, <b>Albert Astals Cid</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">But it won't, even if you disconnect, the error will still be RemoteHostClosedError given that Qt does not reset the error after disconnectFromHost (since there's basically no way to mark "no error"), so if we reconnect after disconnection we will still have RemoteHostClosedError if we ask for the error even if it's not true for this session. Of you mean this in connection with the above hack?</p></pre>
 </blockquote>





 <p>On March 27th, 2016, 4 p.m. UTC, <b>Andreas Hartmetz</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Yeah, what happens here is working around two API mistakes in QTcpSocket: that there is no proper "no error" code, and that the error isn't cleared when starting a new connection. Apart from settings that may reasonably be persistent like e.g. proxy or buffer size settings, a new connection should behave exactly the same as deleting and recreating the socket. Otherwise the API effectively requires you to delete and recreate a socket to get a clean state, which isn't very nice in such a widely used API. (I sometimes do this in internal interfaces, it's a nice technique to avoid errors in reset and clean up code paths - but it causes a little overhead and more work for consumers)
Since the check here is for a specific error code, UnknownError works as a code that isn't that specific one. And if we hack the error code reset, we have what we need. I consider that self defense against bad API, not a real hack.</p></pre>
 </blockquote>








</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">My suggestion is about using the API the way it was intended to be used: never calling error() unless a QAbstractSocket method returns false. So definitely not calling error() in isConnected(), but only after specific API calls that return false.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Albert: if we disconnect, then state() == ConnectedState will be false, and therefore isConnected will return false, as intended.
No need to call error() in that method.</p></pre>
<br />










<p>- David</p>


<br />
<p>On March 26th, 2016, 5:29 p.m. UTC, Albert Astals Cid wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>

<div>Review request for KDE Frameworks.</div>
<div>By Albert Astals Cid.</div>


<p style="color: grey;"><i>Updated March 26, 2016, 5:29 p.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kio
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Qt sockets returns ConnectedState even when error is set to RemoteHostClosedError after a write operation.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">So make ::isConnected also check for RemoteHostClosedError.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">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.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I need this for https://git.reviewboard.kde.org/r/127502/</p></pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Seesms to work fine and the pop3 bugfix i have also works fine.</p></pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>src/core/tcpslavebase.cpp <span style="color: grey">(b9be69d)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/127501/diff/" style="margin-left: 3em;">View Diff</a></p>






  </td>
 </tr>
</table>







  </div>
 </body>
</html>