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.
It seems 'variant' implements thread-concurrency.

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)

Comments

eYra said…
hello...

can u share with me source code for "Transfer Picture from Client to Server (VB6)" because ur code in rapidshare i cant download...email me:nazirahmahud@gmail.com

TQ
Brandon Teoh said…
You can also download from planet source code..

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=72687&lngWId=1
eYra said…
thanks brandon teoh for source code
eYra said…
Hello...

I want to ask you about how to transfer picture from client to server(vb6) in network but in your source code just apply local host.

now i already done sent text in network but for image i cant sent

can u help me, please
Brandon Teoh said…
hi,

Ok. Maybe you can send your email address.

I haven't really tested it out.

The purpose of this sample is to illustrate sending binary data using socket.

But it should work because it is a matter of TCP/IP settings.

You just need to set the remote host public IP at the client side.

You have to make sure that your router and firewall setting is appropriate.

Does it work ?
eYra said…
thanks ur respond...

my email : nazirahmahmud@gmail.com
i already email you.