Results 1 to 5 of 5

Thread: new winsock class

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    new winsock class

    hey all, this is my implementation of winsock
    it's different from other (SocketMaster)
    that it doesn't use any unusual code
    no asm code, nor nothing unusual.

    only simple subclassing.

    the subclassing is safe enough to use,
    it doesn't use dynamic subclassing which may cause problems.
    it can be loaded several on one form, with an index.
    doesn't use subclassing anymore.

    can be freely load/unload dynamicly.


    there is a minor change between vb socket and this,

    methods:
    CloseSck (instead of close)

    Error event has a little different header


    there are two examples include
    one for chat + send/receive file
    second , is the example from apinet

    i also tested it with my mail sender, and it works very well.

    please if you test it, let me know what you think.

    there are two versions: control and class.

    The way to initialize the class is as you init every class.
    Code:
     Dim sck As WSocket
     Set sck = New WSocket
    no additional code is needed.

    the control version doesn't need any init code

    enjoy
    Attached Files Attached Files

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: new winsock class

    sorry, i made some changes, and it's still in progress

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: new winsock class

    hey every one, i'm really glad to tell you that the socket is ready,
    and tested with some apps:
    sending mails
    sending files, with my example and with CVMichael filetransfer example.

    i turn the socket from a class to a contril,
    so it can be loaded with index array.

    the main reason it took me a lot of time, was because a bug in my example
    code not in the socket itself.

    i checked binary string with this code
    Code:
    If Str1$ = "" Then Exit Sub
    this is good only for text string,
    not for binary strings!

    for binary strings, it sould be:
    Code:
    If Len(Str1$) = 0 Then Exit Sub
    it took me a lot of time to find this

    when i found this, i also fixed this bug in the mail program.


    Note:
    this control uses sub classing,
    it does this only when the first socket is loaded,
    and unsubclass when the last socket is unloaded,
    so it's quite safety to use it.
    just remember one thing,
    you should avoid load and unload a form with this socket dynamicly.

    the best way is to load a form with the socket,
    the first one on form_load
    and unload it the last one, on form_unload.

    if you have more forms with this socket,
    you can freely load/unload them dynamicly

    only the first form with this socket
    should be loaded when the app starts
    and unloaded when the app ends.
    doesn't use subclassing any more


    i made a little test, of size:
    with my control you get much smaller exe, than with CSocketMaster.

    i'd like to hear some comments after you test it.

    i'm quite sure you won't regret

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: new winsock class

    i updated the socket, and now it doesn't use subclassing at all.
    it works in its own window.

  5. #5
    Addicted Member
    Join Date
    Mar 2007
    Location
    India
    Posts
    227

    Re: new winsock class

    Thanks for your efforts.

    I have a need to use Sockets for an app that I am developing.

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