// ------------------------------- // // -------- Start of File -------- // // ------------------------------- // // ----------------------------------------------------------- // // C++ Source Code File Name: client.cpp // C++ Compiler Used: MSVC40, HP CPP 10.24, egcs-2.90.29 // Produced By: Doug Gaer // File Creation Date: 09/20/1999 // Date Last Modified: 06/21/2000 // Copyright (c) 2000 Douglas M. Gaer // ----------------------------------------------------------- // // ------------- Program Description and Details ------------- // // ----------------------------------------------------------- // /* The VBS C++ classes are copyright (c) 2000, by Douglas M. Gaer. All those who put this code or its derivatives in a commercial product MUST mention this copyright in their documentation for users of the products in which this code or its derivative classes are used. Otherwise, you have the freedom to redistribute verbatim copies of this source code, adapt it to your specific needs, or improve the code and release your improvements to the public provided that the modified files carry prominent notices stating that you changed the files and the date of any change. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE QUALITY AND PERFORMANCE OF THIS SOFTWARE IS WITH YOU. SHOULD ANY ELEMENT OF THIS SOFTWARE PROVE DEFECTIVE, YOU WILL ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. Demo of the vbSocket WinSock functions. This test program is used to initialize and release various winsock versions and display the contents of the WSAData structure: struct WSAData { WORD wVersion; WORD wHighVersion; char szDescription[WSADESCRIPTION_LEN+1]; char szSystemStatus[WSASYSSTATUS_LEN+1]; unsigned short iMaxSockets; unsigned short iMaxUdpDg; char FAR * lpVendorInfo; // Vendor-specific data structure }; The vbSocket class can be use to automatically or manually initialize the winsock DLL prior to the use of the Windows networking subsystem. Automatic winsock initialization will default to winsock version set in the vbSocket constructor. */ // ----------------------------------------------------------- // #include <iostream.h> #include "vbsocket.h" #include "wserror.h" void PausePrg() { cout << endl; cout << "Press Enter to continue..." << endl; cin.get(); } void PrintWSAInfo(vbSocket *socket) { cout << "WinSock Version Requested: " << (int)LOBYTE(socket->socket_data.wVersion) << "." << (int)HIBYTE(socket->socket_data.wVersion) << endl; cout << "Current WinSock Version: " << (int)LOBYTE(socket->socket_data.wHighVersion) << "." << (int)HIBYTE(socket->socket_data.wHighVersion) << endl; cout << "Description: " << socket->socket_data.szDescription << endl; cout << "System Status: " << socket->socket_data.szSystemStatus << endl; cout << "Max number of sockets: " << socket->socket_data.iMaxSockets << endl; cout << "MAX UDP datagram size: " << socket->socket_data.iMaxUdpDg << endl; } void TestWSAVersion(vbSocket *socket, vbsSocketLibraryVersion ver) { socket->socket_version = ver; if(socket->InitSocketLibrary() == 0) { PrintWSAInfo(socket); cout << endl; cout << "Simulating a WinSock error and printing the extended error info" << endl; WinSockSetException(WSAEINTR); cout << WinSockExceptionMessage() << endl; if(socket->ReleaseSocketLibrary() != 0) { cout << socket->SocketExceptionMessage() << endl; } } else { cout << socket->SocketExceptionMessage() << endl; } } int main() { vbsSocketLibraryVersion wsa_ver10 = vbSOCKET_WSAVER_ONEZERO; vbsSocketLibraryVersion wsa_ver11 = vbSOCKET_WSAVER_ONEONE; vbsSocketLibraryVersion wsa_ver20 = vbSOCKET_WSAVER_TWOZERO; vbsSocketLibraryVersion wsa_ver22 = vbSOCKET_WSAVER_TWOTWO; vbSocket socket; cout << "Testing winsock version 1.0" << endl; TestWSAVersion(&socket, wsa_ver10); PausePrg(); cout << "Testing winsock version 1.1" << endl; TestWSAVersion(&socket, wsa_ver11); PausePrg(); cout << "Testing winsock version 2.0" << endl; TestWSAVersion(&socket, wsa_ver20); PausePrg(); cout << "Testing winsock version 2.2" << endl; TestWSAVersion(&socket, wsa_ver22); cout << endl; cout << "Exiting..." << endl; return 0; } // ----------------------------------------------------------- // // ------------------------------- // // --------- End of File --------- // // ------------------------------- //