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)