How Streams are received



Sorry to labour this point but i have been unable to find anything on the
net or in my books to make this clear to me.

So can someone give me a yes or no on this. I have an asynchronous socket
client/server setup and a receive buffer of 1024. All my data sent has the
size pre-pended to the first 4 bytes.

If i send 1513 bytes to the client is this what happens:

- Client receives 1024 bytes (full buffer)
- Client reads first 4 bytes and gets the length
- client then reads the rest of the buffer into a memorystream and rbuilds
the data client side

- Client gets another recieve for 535 bytes, the remainder of the data.
- Client checks if it is still waiting for more data (due to the data size
expected) and if it is dont calculate data size as this is all data coming
through
- Client reads these 535 bytes and completes the memory stream. Data
transfer complete.


Is that how i will receive everytime regardless of how quickly data is sent?
So if i send 1513 bytes then immediately after send 500 bytes does it do the
same as above for the 1513 finishing on a receive of 535, then doa new
receive for 500 for the next data coming in, the 500 byte send?

If so i presume it is impossible to have surplus data or redundant data in
the buffer? As you will either be filling it or only receiving thw amount of
bytes left? Is that understanding correct.

I hope someone can set me straight at long last on this trivial point.


.



Relevant Pages

  • Re: Socket write behaviour is inconsistent?
    ... copy 1 byte to buffer, copy many bytes to buffer, copy one byte to ... Then why did you write "the client throws an error"? ... remote endpoint for your connection. ... When the response is sent using the first chunk of code, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: TCPClient Synchronous or Asynchronous Writes
    ... acting as the "server" receives quality assurance data from different ... Each client can register to look at differnt data so there ... is actually a Circular Buffer for each client. ... >> stream data to my clients over a TCPClient connection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: NIO best practice
    ... ByteBuffer buffer) { ... SelectionKey key=client.keyFor; ... ChannelState state=selkey.attachment; ... transfer_file(selkey, client, state); ...
    (comp.lang.java.programmer)
  • Re: USB data Transfer question
    ... I'm afraid you can't pass 1-byte length buffer ... the pBuffer!=0 if there is data sending from client. ... and both USB analizer and the pBuffer value is the ... and the write function which write data from USB host to client works ...
    (microsoft.public.windowsce.platbuilder)
  • Re: TCPClient Synchronous or Asynchronous Writes
    ... there's no guarantee the first packet of data ... post it off to the client every few seconds in one block. ... > stream data to my clients over a TCPClient connection. ... > On the server I have a custom circular data buffer that receives byte ...
    (microsoft.public.dotnet.languages.csharp)