Re: c# sending a bitmap by socket

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Thu, 07 Jun 2007 03:52:35 -0700, david wrote:

I have a client/server application. the server capture picture from
webcam and send it to every client connected to it.the network part
works good and the capture from webcam too. I associate an event when
a capture is done, then every frame of the webcam should be sent to
the client.
but I cannot find a way to send bitmap throught network, of course I
found many method from internet, some doen't work, some work but it's
never stable.
[...]
This method doesn't work good and is not stable.

What do you mean with "doesn't work good" and "not stable"? The piece of
code you gave us contains for too many references to undeclared variables.
I can't make any sense of it. It looks overly complicated to me as well.

Is it possible by an other method to skip to send the picture size?

If you don't first send the picture size, how could the receiver possibly
know how many bytes it has to read before it has read the entire picture?
The only way to not send the picture size first (by picture size you
actually mean the number of bytes formed by the picture's data) would be to
design your network protocol so that a particular sequence of bytes
appended at the end of the picture's data signals that the picture is
complete. This would make the implementation of the receiver side more
complex and probably less efficient. Plus given that the picture data can
potentially contain any combination of bytes, you'd need to make sure that
it doesn't contain your End-Of-Image byte sequence which adds further
complexity.

What is the real and best method that works, never failed, to send
picture from webcam by socket in c#?

There's no "real" and "best" method to send pictures over a socket. The
first thing that you should do is sit down and design a suitable network
protocol. If you have never designed a network protocol before, I would
suggest that you download the specifications of some network protocol and
see what it looks like (the VNC network protocol is a very simple and easy
to understand protocol. The documentation is well written too so that could
be a good starting point <http://www.realvnc.com/products/personal/4.2/>).

In your particular case, if all you want is send images from the server to
the client, your protocol is probably going to be most basic. Something
like that for example:

Server Sends:
MessageLength Type Description
4 bytes UInt32 (BigEndian) ImageDataSize
ImageDataSize byte array Image Data

Then use your NetworkStream Send or BeginSend and Read or BeginRead methods
to implement the protocol. If your webcam image grabber code raises events
in worker threads, make sure that you do not start sending the next image
while you are still in the process of sending the previous one.
.



Relevant Pages

  • Re: Problem for physicalist evolutionists
    ... does not a neural network make. ... they do no need to communicate anything ... along any of those network connections to "assemble" the picture. ...
    (talk.origins)
  • Re: Problem for physicalist evolutionists
    ... does not a neural network make. ... potential to have an FPP, and the FPP will be some part of that ... along any of those network connections to "assemble" the picture. ...
    (talk.origins)
  • Re: Problem for physicalist evolutionists
    ... does not a neural network make. ... they do no need to communicate anything ... along any of those network connections to "assemble" the picture. ...
    (talk.origins)
  • Re: Problem for physicalist evolutionists
    ... does not a neural network make. ... along any of those network connections to "assemble" the picture. ... Communication is not necessary for that FPP to have an FPP of the ...
    (talk.origins)
  • Re: Problem for physicalist evolutionists
    ... does not a neural network make. ... potential to have an FPP, and the FPP will be some part of that ... along any of those network connections to "assemble" the picture. ...
    (talk.origins)