A C++ Base Class for Winsock
GENISYS Comm retains rights to the source code included with this distribution dated 7 Nov 93.
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 commercially developed products.
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 prototyped.
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 developed 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 single Listen() function, returning an error code if unsuccessful.
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 first 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 names 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:
mail:GENISYS Comm, 314 S. Jay St, Rome, NY 13440
fax:315-339-5528ons, we capitailized each word's first letter ixtp"l7hSda`\X~TPLV^N^wsoQk7hSda`\X~TPLV^N^xx "7QSafa|~<)?Safa|~< Arial