How wqweto/vbasyncsocket works
Project type and purpose
• This is a VB6-based networking library that wraps Windows WinSock APIs (cAsyncSocket) and provides transparent TLS support (cTlsSocket) with three interchangeable backends (mdTlsThunks, mdTlsNative, mdTlsSodium).
• It targets VB6 client and server applications needing asynchronous or blocking TCP and TLS 1.2/1.3 communication without external dependencies (or with optional libsodium).
File structure
• Top-level directories:
• src/ – core classes and TLS backends in VB6 modules.
• lib/ – C implementations of cryptographic primitives (ASM thunks, mini-gmp, ChaCha20, AES-GCM, curve25519, RSA, etc.) and a prebuilt certificate.
• contrib/ – optional VB6 wrappers for HTTP (cHttpDownload, cHttpRequest), rate limiter, WinSock remastering, plus DLL projects for native HTTP and TLS controls.
• samples/ – example VB6 apps demonstrating basic sockets, TLS socket tests, HTTP replacement, VBScript snippets.
• test/ – extensive VB6 test harnesses covering bare-bones TLS, basic socket, chat server/client, crypto operations, secure connections with certificates, various WinSock demos.
• Config and build files: .gitmodules, Visual Studio/C++ project files under lib/thunks and contrib/dll.
README for additional insights
• Describes the library’s layering:
• cAsyncSocket – non-blocking socket wrapper.
• cTlsSocket – subclass of cAsyncSocket that delegates TLS encryption/decryption to a chosen backend.
• Backends:
– mdTlsThunks – pure VB6 + ASM thunks, no external deps, optimized for AES-NI.
– mdTlsNative – uses Windows SSPI/Schannel via VB6 declarations.
– mdTlsSodium – relies on libsodium DLL, compact.
• Shows sample code flow: plain socket → STARTTLS → TLS handshake → secure send/receive.
Detailed elements
• Three branches from “TLS Backend” to: “mdTlsThunks (ASM/C)” , “mdTlsNative (SSPI)” , “mdTlsSodium (libsodium)”
• Overlay: “contrib/cHttpRequest” sitting on top of cTlsSocket for HTTP integration