A C++ Base Class for Winsock Copywrite Notice GENISYS Comm retains rights to the source code included with this distribution dated 7 Nov 93. Distribution Policy GENISYS Comm releases this software into the public domain, and allows it to be copied and distributed freely with notice to the author. The existing copyright notice must be preserved in the source code, and credit given to GENISYS Comm for any commerc ially developed products. Introduction It has become apparent to the author that the WINSOCK specification call out for a C++ standard along the lines of the MFC definitions. As he has already implemented several such classes for his GCP++ product, the enclosed definition was quickly prototy ped. The reader's initial reaction may be to question the need for such a definition. As implemented here, the CWinsock base class is little more than an encapsulation of the winsock functions with internal data items for the socket descriptor, window, and callback message. To these readers I respond with "Yes, you are correct. But the elegance of the CWinsock class is that it provides a base class for special derived classes, providing structure for encapsulation and future state and error checking". The CWinsock class definition is not completed, as it does not yet provide error checking, etc. This will be competed in the Beta version. Comments from Readers Please forward your comments to the author, and your suggestions will be folded into future versions of the spec. Derived Class Example Although the CWinsock base class defined could be used "as is" (all the function members are public for this purpose), the author recommends that it be used primarily as a base class for specific applications. For example, a CTcpDaemon class could be de veloped that adds a Listen(unsigned int Port) member function. This function would create a TCP socket, bind it, and listen on the port specified. Since all these function are synchronous blocking, all the functionality could be included within the sing le Listen() function, returning an error code if unsuccessful. Naming Conventions Before we figured out how to eliminate the naming confusion between the WINSOCK calls and our class calls, we modified the class function names and adopted a standard (non-BSD UNIX) format. For non-WSA Winsock functions, we capitailized each word's fir st letter in the CWinsock class function. For WSA functions, we removed the WSA prefix. We like the result, and would prefer to keep it if there is no great objection. I'm sure that those involved with the original naming (adopting the BSD function nam es and parameters) will have something to say. I only ask you consider that since the arguments must change, this would be a good time to adopt a consistent naming convention. Contacting the Author Michael Baldwin can be reached by: e-mail: baldwin@GENISYS.com mail: GENISYS Comm, 314 S. Jay St, Rome, NY 13440 phone: 315-339-5502 fax: 315-339-5528