Transfer Picture from Client to Server (VB6)
This sample code in VB6 demonstrates sending picture or image file from a client to server software via Winsock using TCP.
Initially I thought it was easy. I was wrong.
The challenges are:
- Maximum packet size using socket is 8191 bytes, thus if the picture/image is more than, the image will be transferred via socket in multiple packets.
- In VB6, I have discovered that array variable can only be passed as by reference (byRef) parameter. Since there is no way to pass an array byVal and there is no way to perform thread-concurrency on the process of winsock.GetData(), the best practice is to use 'variant' to fetch binary data which comes in multiple packets instead of using byte array.
If you attempt to use byte array to fetch the binary data, the end result image file would be corrupted. This will be explored in the next blog.
Download the sample code (VB6)












![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=e8e7f836-f0ea-483f-bc25-3dcaa793092a)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=8604b033-ef67-44cd-a8f1-fb49357b4cc4)







