Re: TCPClient Synchronous or Asynchronous Writes
- From: "Jeff Weber" <JeffWeber@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 18 May 2005 06:58:08 -0700
Dan, thanks for the response.
Here are the details of my situation.
There are 5 computers sitting around a manufacturing machine. The computers
are connected by a fairly high speed closed network. One of the 5 computers
acting as the "server" receives quality assurance data from different
measurement devices situated around the machine. The max rate that the
machine can send this measurement data to the server is ~30ms. The data
comes into the Server as byte arrays representing various data structures.
The goal is to get this data out to each of the 4 clients so that it can be
displayed graphically to the machine operators. The data has to arrive as
close to real time as possible (it can lag a little) and it has to be in
order.
Currently, as the data comes into the server it is immediatly Enqueued into
a Circular Buffer. Each client can register to look at differnt data so there
is actually a Circular Buffer for each client. A seperate thread running on
a high performance timer constantly pulls (Dequeues) items from the Buffers
and sends them (via tcp/ip) to each client.
Once the client receives a data item, it throws that item into a client side
Circular Buffer. Another thread on the client, again running on a timer,
pulls items from this buffer and displays the data.
FYI, each data structure is ~200-300 bytes.
I'd be interested in hearing other solutions. For now, I think I will look
into possible sending items from client to server in groups rather than one
at a time. Is it your opinion this would improve my performance, since my
send rate would be lower. (even though the size of the data being sent would
be larger.)
"Dan Bass" wrote:
>
> 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!
> >
> >
> >
> >
>
>
>
.
- Follow-Ups:
- Re: TCPClient Synchronous or Asynchronous Writes
- From: Dan Bass
- Re: TCPClient Synchronous or Asynchronous Writes
- References:
- TCPClient Synchronous or Asynchronous Writes
- From: Jeff Weber
- Re: TCPClient Synchronous or Asynchronous Writes
- From: Dan Bass
- TCPClient Synchronous or Asynchronous Writes
- Prev by Date: Re: C# Newby String to Char Conversion question
- Next by Date: RE: Lacking for-loop optimization in C#
- Previous by thread: Re: TCPClient Synchronous or Asynchronous Writes
- Next by thread: Re: TCPClient Synchronous or Asynchronous Writes
- Index(es):
Relevant Pages
|