Re: TCPClient Synchronous or Asynchronous Writes




Generally, if order is that important you should stick with synchronous. If
you go the asynchronous route, there's no guarantee the first packet of data
will arrive before the second... In my thinking you'd only use the
multithreading option if sending to multiple clients.

Hitting TCP this often and hard wouldn't be desirable for any network.
Because the rate is so high, is there an option of buffer up your data and
post it off to the client every few seconds in one block. The client would
then separate the data into sub-blocks it needs again. There'd also be
facility here then to handle things like dropped connections, where the data
that is ready to send gets buffered up until the connection is
re-established.

Out of curiosity, what the scenario surrounding these few stages? Perhaps
there are other ways of doing what you are trying to accomplish.

Good luck.
Dan.

"Jeff Weber" <Jeff Weber@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:020BA73A-692C-43AF-BF17-FB5021DA7A0B@xxxxxxxxxxxxxxxx
> First, my question: Should I use Write or BeginWrite (sync or async) to
> stream data to my clients over a TCPClient connection.
>
> Details:
> On the server I have a custom circular data buffer that receives byte
> array
> data representing data structures at a rate of 30ms.
>
> On a thread seperate from that which Enqueues data to the buffer I have a
> high performance timer that Dequeues data from the custom buffer and sends
> it
> via a tcpClient connection to the client. The Dequeue timer runs at a rate
> greater than or equal to the Enqueue rate so the buffer never fills up.
>
> On the Client I have a similar custom data buffer that will buffer the
> data
> it receives from the server until it can be displayed.
>
> My data needs to be displayed in the order it was originally created.
>
> I have googled the internet for hours but I am still not sure if I should
> be
> sending my data to the client using Write or BeginWrite/EndWrite. I know
> that with Write I am gauranteed the proper order, which is good, but will
> Write be able to keep up performance wise? Or should I use
> BeginWrite/EndWrite, then have logic on the client to make sure things are
> in
> the correct order.
>
> Any insight into this is very appreciated!
>
>
>
>


.



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: append to the recv socket buffer
    ... so i listen to one client and ... Then I allocate a buffer ... then define one big buffer and append data to it as i am looping ... with the first packet? ...
    (comp.unix.programmer)

Loading