Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your telnet example is somewhat contradictory to the behaviour of the code that you describe - if you are ever able to get anything on the server, the "telnet &lt;hostname&gt; &lt;portnumber&gt;" should get you to a blank screen pretty quickly (on windows machine in the CMD prompt that is). So, this is the first strange thing - best debugged with <a href="http://www.wireshark.org/" rel="nofollow noreferrer">wireshark, though</a>.</p> <p>Code-wise, I think it may be problem with this inner line on the server:</p> <p>... while ((0 &lt; len) &amp;&amp; (ns.DataAvailable == true));</p> <p>You say that you want to loop while you were able to read something and while there is some data available.</p> <p>However, it may be that the second segment has not made it to the server yet, so there is no data available yet, so you are falling out from this loop.</p> <p>You should loop receiving data while you are reading something and while there has not been any read error - this guarantees that even on the slow links you will reliably receive the data.</p> <p>A side note:</p> <p>I notice your protocol is request-response-request-response type. It works well on the LAN, however if you need in the future to make it work over the high-round-trip-time links, this will become a big performance bottleneck (MS SMB protocol used for filetransfers or TFTP works in this fashion).</p> <p>(Disclaimer: I didn't code in C# much, so might have been wrong in the interpretation of "DataAvailable()" method, take this FWIW).</p> <p>Edit: probably my answer above would need to be corrected according to your protocol - i.e. you'd need to first read the length of the file, and then read the file - since if you take it verbatim it will break the way you designed it completely.</p> <p>That said, with TCP one should never assume the number of write() operations on the sender side is the same as number of read() operations on the receiver side - in some cases it may be the case (no packet loss, no Nagle) - but in the general case it would not be true.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload