VB6 "Full Duplex functionality?" ActiveX? Threads?
Posted on 2003-03-17
I'm working on a small project using VB6 but I've run into a problem. There will be a single client and a single server communicating over TCP/IP in this app. They both have the same functions (called peers?)
The server's ongoing job is to perform very large tasks that result in large amounts of data to be sent to the client (just for example, a sampled wave file compressed using zlib)
The client's ongoing job is to receive the large amount of data, perform tasks upon it (such as decompression, decryption what have you) and present it to the user.
This model works fine, however I want a full duplex style of functionality. The problem at the moment is that whilst say the client is decompressing data, the client is incapable of sampling it's OWN wave file and compressing that data, or even of sending any uncompressed data to the server.
Similarly, the server is "frozen" during compression, or during data transmission. To sum up, I need both the server and the client to have the ability to do the following 2 things at once:
1.) (Sample and encode and send data)
2.) (Receive and decode and present data)
To be as clear as possible:-
The server must be able to "sample for a few seconds and send that sample to zlib" non stop, yet somehow also be instantly ready to receive and decompress data to be presented, even whilst in the middle of compressing outbound data.
I've tried using the CreateThread() in Kernel32 in both VB5 and VB6 (lol that was pleasant) with little success and would prefer to abandon that avenue.
Using timer() and DoEvents didn't seem to work very well for me. As the data is being sent to an external function (say zlib), I don't understand how I can inject DoEvent statements into the execution of compress() as used in Zlib. I.e I merely call it and have no choice but to wait until it returns the compressed data. All the while, the user might be talking into the mic, but nothing is recorded! My problem is that the compression job takes the most time, so switching out of it momentarily only seems possible with threads.
I've thought about migrating it to a c++ project. I have very little knowledge in c++, however I understand java very well and I expected MS Visual C++ to resemble either Borland's JBuilder or Visual Basic 6's IDE. The MS VC++ interface was intimidating! Migrating the project is a last resort option as it'll add weeks
to the development time (as I need to learn it)
I've thought about buying the .Net varient of Visual Basic after reading it has native threads support. This would be an ideal solution even if I couldn't copy and paste lots of code over. How different is VB.Net or VB7 whatever its called? ;)
My only issue is the possibility of needing a common runtime package. I don't want to add 20mb to the download size should I want to put this app up on the web. Can VB7 be used without the common runtime package if the class system of .Net is never used? Are threads part of that class system? Eek...
I've read a few other questions on threading and ActiveX in good old VB6 but I didn't understand very well. Would I need a main ActiveX executable and several ActiveX DLL's in the case of this project?
Would this work:
ActiveX Sample, Call Zlib and TCP send.DLL
ActiveX Receive, Call Zlib and Present ZLib Caller.DLL
I guess that the sampler dll would also have to be responsible for sending the data over tcpip, and the presenter dll would have to be responsible for collecting data off the stack as the two things need happen at once right?
The threading model options available to ActiveX didn't make much sense to me after reading the Docs. I am a bit new to threads
Any suggestions or ideas would be highly appreciated!