Send Image From to PPC

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to send an image file (a byte[] retrieved from MS SQL &
serialized before sending) from PC to PPC. However, only around 32bytes of
data can be received and displayed in a pictureBox of app in my PPC.

But there is no problem if doing so from PC to PC. Can anyone give me some
idea over the cause of such problem.
 
Did you use WebServices for it? Or you have created custom method to
transfer this image between client and server? Provide us with more
information and if it is possible with small code to reproduce your problem.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
Thanks for your reply.

No WebService is used in our case. Actually, I am trying to pass a byte
array of bitmap image from PC to PPC through a socket connection. After the
connection is established, binarystream writer is used to send the image to
PPC.
As a result, only 32KB of the image is read, however, its actual size is
63KB. If the image is ever larger, eg. 700KB, only black color is painted on
the picture box.

Sergey Bogdanov said:
Did you use WebServices for it? Or you have created custom method to
transfer this image between client and server? Provide us with more
information and if it is possible with small code to reproduce your problem.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Ted said:
I am trying to send an image file (a byte[] retrieved from MS SQL &
serialized before sending) from PC to PPC. However, only around 32bytes of
data can be received and displayed in a pictureBox of app in my PPC.

But there is no problem if doing so from PC to PC. Can anyone give me some
idea over the cause of such problem.
 
How do you know when the end is reached? If you are relying to
NetworkStream.DataAvailable then the problem is here. Look at this small
example how you can read byte stream:

NetworkStream ns = tcp.GetStream();
using(FileStream fs = new FileStream("/stream.dat", FileMode.Create))
{
// tries 5 times before exit
for(int i = 0; i < 5; i++)
do
{
bytesRead = ns.Read(buffer, 0, buffer.Length);
if (bytesRead == 0) break;
fs.Write(buffer, 0, bytesRead);
}
while(ns.DataAvailable);
}
ns.Close();

DataAvailable may returns false even if the operation was not completed.
I suggest you to consider asynchrous sockets [1] instead and implements
timeout by yourself (using event objects for example).

[1]
http://msdn.microsoft.com/library/d...e/html/cpconusingnon-blockingserversocket.asp


Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Ted said:
Thanks for your reply.

No WebService is used in our case. Actually, I am trying to pass a byte
array of bitmap image from PC to PPC through a socket connection. After the
connection is established, binarystream writer is used to send the image to
PPC.
As a result, only 32KB of the image is read, however, its actual size is
63KB. If the image is ever larger, eg. 700KB, only black color is painted on
the picture box.

:

Did you use WebServices for it? Or you have created custom method to
transfer this image between client and server? Provide us with more
information and if it is possible with small code to reproduce your problem.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Ted said:
I am trying to send an image file (a byte[] retrieved from MS SQL &
serialized before sending) from PC to PPC. However, only around 32bytes of
data can be received and displayed in a pictureBox of app in my PPC.

But there is no problem if doing so from PC to PC. Can anyone give me some
idea over the cause of such problem.
 
Back
Top