You really need to profile your application and find out if it is simply the
reading pegging your CPU
or if something else is happening. When you do a Receive or a Send there isn't
any copying of data
between the managed and unmanaged world which you might normally think to be a
bottleneck.
Instead, your buffer is simply allocated a GCHandle and then the address of your
pinned array element
is retrieved based on your offset. This address is passed directly into recv on
the Win32 side.
I'm not sure, but it might be possible that your manipulation of the data as it
is received is the bottleneck.
If you are actually loading the bytes into a Bitmap object or allocating large
amounts of memory, possibly
not using shared buffers, or writing to disk where you have a file IO
bottleneck. Lots of things can be
happening.
4.5 MB/s is actually pretty decent, that is 36 Mb/s which is starting to push
the speed of file IO on older
systems. I have some computers around that can't handle those types of speeds
in the least.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog:
http://weblogs.asp.net/justin_rogers [quoted text, click to view] "Jerome Symons" <jerome.symons@adi-limited.com> wrote in message
news:9fb0bff1.0402172210.6d5e04de@posting.google.com...
> Hi everyone,
>
> I have developed a C# client/server system that creates bitmap images
> at the server and sends them to the client as an array of bytes using
> a Socket.
>
> When the data rate through the socket reaches about 4.5 MB/s, the
> Socket.Read command at the client end uses all of my CPU. I don't know
> why it takes so much CPU to read the data from the socket.
>
> My socket is a TCP/IP stream type socket and the images that are sent
> from the server are about 300 kB in size. I am able to send about 15
> images/s before the communication between the server and client breaks
> down. I am assuming that this is happening because the CPU for the
> client runs out of steam.
>
> Thanks for any help.
>
> Jerome
>
> PS - No I cannot use jpeg compression to reduce the size of the
> images.