NetworkStream.Read synchorization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hai Ly Hoang \(MT00KSTN\)

    #1

    NetworkStream.Read synchorization

    Hi,
    FileStream.Read (buf, offset, siz) will return when reaching the end of file
    or a block (size siz) can be read from the file. In the case of
    NetworkStream, it's more confusing. Now, consider this case:

    The server send a block of 15 letter A. At the time NetworkStream.R ead is
    called (on client machine), the client machine has only received 3 letter A:

    Server (send): AAAAAAAAAAAAAAA
    Client (receive): AAA
    ^___ Read(buf, 0, 50) methods is called.

    Do Read method will delay until 15 letter A are received and return a block
    of 15 letter or Read methods just return a block of 3 letter A (ie. return
    what data the client has received) ?
    If Read methods returns 3 letter A, how do we determine whether the server
    has send all of its data ?

    Thanks



Working...