It also demonstrates concurrent socket handling within Visual BASIC 6. The Winsock Control is used for simplicity. It implements a simple protocol for passing header information and basic error control.
This program was written to implement a DCC Send style function.
The protocol is very simple for implementation in other programming languages (e.g. C++, Java and C#).
Header:
12 bytes : 0 extended decimal file name length in bytes (string, e.g. '000000000010'=n)
n bytes : file name (string, e.g. 'winzip.log')
12 bytes : 0 extended decimal file length in bytes (string, e.g. '000000125531'=m)
Body:
m bytes : {file body}
The program uses port 1000, configurable on the form. The listener must be running before the server connects.
bug fixes:
1. extra null data was caused by reading an extra chunk due to VB arithmetic round up error,
2. race condition fixed by client closing the socket when all data has arrived, not the server.
performance improvements:
1. only reallocate read buffer if more data arrives than previously allocated
each data arrived event can get a different number of pending bytes potentially,
we keep the buffer set to the highest number received so far for efficiency.
2. read chunk size increased to 32000 bytes.
user interface improvements:
1. file browse button added,
2. doevents used in sender to yield to other threads.
30/12/2005
Version 0.7
1. block socket close attempt from server when client is still receiving.
30/12/2005
Version 0.6
1. sender doesn't send whole path, just filename,
2. version number set correctly.
30/12/2005
Version 0.5
1. Last packet size read correction,
2. copy filename from source for output file.
Back to index.