Results 1 to 40 of 50

Thread: VB6 UniSock: winsock replacement [2008-08-14]

Threaded View

  1. #1

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    VB6 UniSock: winsock replacement [2008-08-14]

    This is my attempt in writing a Winsock class module. The major difference to other implementations is that there are no other files, it is just one class file. By syntax and behavior I've tried to make it imitate the Winsock control when it has made sense. The major syntax differences are the Close event (changed to Closing) and Close method (changed to CloseSocket). I have also adjusted the datatypes, so instead of variants there are more precise datatypes used when appropriate. This allows VB's autocomplete to work.

    Unlike other implementations you can use a wide variety of arrays, even string arrays, for both getting and sending data. I've also paid attention in keeping the class efficient & lightweight. There are also small convenience features: many of the methods are now functions that return a boolean value.

    The greatest difference to other Winsock implementations is a switch between binary mode and text mode. In text mode you are only able to process text data (ideal for entirely text based conversation, such as IRC). Text mode also disables DataArrival event and enables TextArrival event. Text mode's true power is in that it automatically processes incoming Unicode strings for you, namely UTF-8 and UTF-16. If you expect to receive Unicode data, you don't need to care about it. If you receive ANSI text in TextArrival, you must use StrConv or other method to process the string to displayable form.

    I have done testing only with TCP. This means UDP portion of the code is untested. My tests even on TCP side aren't full scale, so if you run into any oddness I'd like to know about it.


    A small sample project is included that demonstrates a continuously listening server, a client and a new socket accepted by server when the client connects. The code should be fairly well commented.
    Attached Files Attached Files
    Last edited by Merri; Aug 14th, 2008 at 03:45 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width