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)


cik ira said…

can u share with me source code for "Transfer Picture from Client to Server (VB6)" because ur code in rapidshare i cant

Brandon Teoh said…
You can also download from planet source code..
cik ira said…
thanks brandon teoh for source code
cik ira said…

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…

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 ?
cik ira said…
thanks ur respond...

my email :
i already email you.