Hi all,

I have a problem with Winsock in my application and I really don't know how to fix it. I'm developping a .dll for a web application by the way.

I checked the box "Microsoft Winsock Control 6.0 (SP5)" in the Project>References menu.

In the webclass, when I click a button, I create a Socket, set some information and try to connect
VB Code:
  1. Dim mySocket As EPSocket
  2.         Set mySocket = New EPSocket
  3.         mySocket.mPort = 10000
  4.         mySocket.mServer = "localhost"
  5.         Call mySocket.CreateConnect
I'm using a class called EPSocket because otherwise VB wouldn't let me create an object with the WithEvents declaration, which I need (at least I think I do).

The EPSocket class:
VB Code:
  1. Option Explicit
  2.  
  3. Private WithEvents oWinsock As MSWinsockLib.Winsock
  4.  
  5. Private mvarmServer As String
  6. Private mvarmPort As Integer
  7.  
  8. Public Property Let mPort(ByVal vData As Integer)
  9.     mvarmPort = vData
  10. End Property
  11.  
  12. Public Property Get mPort() As Integer
  13.     mPort = mvarmPort
  14. End Property
  15.  
  16. Public Property Let mServer(ByVal vData As String)
  17.     mvarmServer = vData
  18. End Property
  19.  
  20. Public Property Get mServer() As String
  21.     mServer = mvarmServer
  22. End Property
  23.  
  24. Private Sub Class_Initialize()
  25.     Set oWinsock = New MSWinsockLib.Winsock
  26. End Sub
  27.  
  28. Public Sub CreateConnect()
  29.  
  30.     oWinsock.Connect mvarmServer, mvarmPort
  31.  
  32. End Sub
  33.  
  34. Private Sub oWinsock_Connect()
  35.  
  36.     oWinsock.SendData CStr("Hello World")
  37.     oWinsock.Close
  38.    
  39. End Sub
  40.  
  41. Private Sub oWinsock_Close()
  42.     Set oWinsock = Nothing
  43. End Sub
  44.  
  45. Private Sub oWinsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, _
  46. ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  47.  
  48.     Debug.Print Description
  49.  
  50. End Sub
The problem is: the Socket is created without problem, the connection happens, but the oWinsock_Connect function is never run. I'm probably overlooking something really obvious, but I just can't figure it out. Any ideas?
Thanks,
Ilyas