Results 1 to 22 of 22

Thread: Winsock Class

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Winsock Class

    Is there a winsock class with options: connect, accept, send, recv, etc. ??

    other than Wokawidgets[his doesnt work in .dll format, it errors like failed to initialize 0x0000005])

  2. #2
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Winsock Class

    If you have access to VB.NET you may want to check that out. That can definitely do what you're looking for.

    As far as networking in VB6, I'm only personally aware of the Winsock control you put on a form.

    But hey! You can make a form in an Active X dll. Just make it invisible.

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock Class

    You can find many links for winsock, in VB. It is a component that you can add to your project, and contains the functions that you posted. Woka added them to a dll, but you don't have to. Search for CHAT PROGRAM, and you'll find many links. I think you would look in the Networking Forum.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Winsock Class

    Quote Originally Posted by umilmi81
    But hey! You can make a form in an Active X dll. Just make it invisible
    When I do that using the Winsock control and call it doing "Msgbox Form1.Winsock1.LocalIP" it just simply doesn't work at all. And when I do it with showing the form it errors "Out of Memory".

    Thus why I cannot use components in DLL

    I have searched and searched countless forums, websites, etc. for the last 4-5 months and have yet to find a GOOD vb6 winsock class that works and doesn't error when used in a DLL(no .exes involved) - like I stated in my first post.

    I guess I will just have to give up on this idea.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock Class

    Here is PINO's example. Try each project separately, so that you can connect to yourself, unless you compile on two different machines, and change the IP address on both for send/receive. 39npeople have downloaded this so far. Thanks, PINO

    http://vbforums.com/attachment.php?attachmentid=41575

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Winsock Class

    That link just shows a .JPG file

  7. #7
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Winsock Class

    Patients grasshopper.

    This is VBForums.com. The answers will come.

    Check this out. How are you accessing the form? Don't try to access the form in the Active X DLL directly. Write a property or a function. I was able to get the IP from the winsock control inside active X dll.

    This will be a little tricky if you're not used to Active X development, but it is doable.

    Inside the class of the ActiveX DLL, I have this code:
    VB Code:
    1. Public Property Let RemoteHost(Value As String)
    2.     Form1.Winsock1.RemoteHost = Value
    3. End Property
    4. Public Property Get RemoteHost() As String
    5.     RemoteHost = Form1.Winsock1.RemoteHost
    6. End Property

    Inside the calling application I have this code
    VB Code:
    1. Dim mycls As Project1.Class1
    2.     Set mycls = New Project1.Class1
    3.    
    4.     mycls.RemoteHost = "test.com"
    5.     MsgBox mycls.RemoteHost

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock Class

    Oops. Try this one. I've deleted the jpg.

    http://vbforums.com/attachment.php?attachmentid=38218

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Winsock Class

    VB Code:
    1. Public Property Let LocalIP(Value As String)
    2.     Form1.Winsock1[b].LocalIP =[/b] Value
    3. End Property
    4. Public Property Get LocalIP() As String
    5.     LocalIP = Form1.Winsock1.LocalIP
    6. End Property
    I know the above is different from what you posted but It errors "Wrong number of arguments or invalid property assignment" on the bold.


    dglienna, that is the Winsock Control and I need a Class. Thanks for trying though

  10. #10
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Winsock Class

    Quote Originally Posted by Tantrum3k
    VB Code:
    1. Public Property Let LocalIP(Value As String)
    2.     Form1.Winsock1[b].LocalIP =[/b] Value
    3. End Property
    4. Public Property Get LocalIP() As String
    5.     LocalIP = Form1.Winsock1.LocalIP
    6. End Property
    I know the above is different from what you posted but It errors "Wrong number of arguments or invalid property assignment" on the bold.


    dglienna, that is the Winsock Control and I need a Class. Thanks for trying though

    That statement will error out even if it's not in the Active X control. I don't know a lot about the Winsock control, but I know a fair bit about ActiveX DLL's. If you have a working stand alone application that uses the Winsock, we should be able to help you get it ported to an ActiveX DLL.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Winsock Class

    My .dll is different than the normal vb6 behavior. I use an add-in called "vbAdvance"( http://www.vbadvance.com ) that allows vb6 to create standard Win32 DLL's that export functions - which works perfect.

    But if you want to test it before posting it back to me - you will have to download and install the vbAdvance add-in. (What you do is get an .exe program developed in another language and attach your vb6 .dll to it so it loads with it, which is easy to do)

    I'll attach the project to this thread in hopes that you guys can perhaps help me out a bit with my task.
    Attached Files Attached Files

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock Class

    You'd have to contact the author of that code. We can't support it, even if you have the source code, which I haven't even checked. I don't think it's even necessary to have 4 commands in winsock.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Winsock Class

    All I need to know how to do is what umilmi81 has done in his ActiveX DLL with the Form and Winsock control. I can take care of the rest.

  14. #14
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Winsock Class

    Ok, I went the extra mile for you here.

    Attached is the dg's client converted to an ActiveX DLL.

    I'm not happy with how I process the data received event, but the data send is good.

    This is certainly enough to get you rolling.
    Attached Files Attached Files

  15. #15
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Winsock Class

    Quote Originally Posted by Tantrum3k
    My .dll is different than the normal vb6 behavior. I use an add-in called "vbAdvance"( http://www.vbadvance.com ) that allows vb6 to create standard Win32 DLL's that export functions - which works perfect.
    Now why would you want to do that? COM is

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Winsock Class

    My dll only has one form which is the one inside itself - doesn't use .exe. Will this still work? because it's erroring "Out of Memory" again


    Quote Originally Posted by umilmi81
    Now why would you want to do that? COM is :1337:
    I like the fact that vb6 dll's can now export functions so I don't have to do C++

  17. #17
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Winsock Class

    there is something out there called CSocketMaster.
    It is a class for doing the stuff the Winsock control does
    http://www.freevbcode.com/ShowCode.asp?ID=6485

  18. #18
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Winsock Class

    Quote Originally Posted by moeur
    there is something out there called CSocketMaster.
    It is a class for doing the stuff the Winsock control does
    http://www.freevbcode.com/ShowCode.asp?ID=6485
    Is there an advantage to that? Besides no ocx?

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Winsock Class

    I have tried CSocketMaster but I can't get the Connect to work properly neither in .dll format also.

    I tried:
    VB Code:
    1. mSocket.Connect "66.66.66.66", 9800
    2.  
    3. If mSocket.State = sckError Then
    4.      MsgBox "Cant connect"
    5. End If
    6.  
    7. If mSocket.State = sckConnected Then
    8.      MsgBox "Connected"
    9. End If
    10.  
    11. MsgBox mSocket.State 'always returns sckConnecting
    It always returns sckConnecting and doesn't do anything else (even when the server is up) and returns sckConnecting and doesnt do anything else instead of returning sckError when the server is down.

    Could someone post a good test example using CSocketMaster with DataArrival, Connect, Accept, SendData, GetData, etc. ?

  20. #20
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Winsock Class

    Is there an advantage to that? Besides no ocx?
    The two main advantages are, no OCX and you get the source code to play around with.

    Tantrum, Did you run the examples the code comes with?

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Winsock Class

    It works in .exe but fails to work in .dll.

    In .exe when trying to connect to a server that ISN'T up, it says Connection refused - like it should. When in .dll, it just continues to do nothing.

  22. #22
    New Member
    Join Date
    Nov 2005
    Posts
    1

    Re: Winsock Class

    Is there anyway that the client can terminate the connection ?

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