|
-
Jul 12th, 2005, 07:42 AM
#1
Thread Starter
New Member
[VB6] Problem with Winsock in Class module
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:
Dim mySocket As EPSocket
Set mySocket = New EPSocket
mySocket.mPort = 10000
mySocket.mServer = "localhost"
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:
Option Explicit
Private WithEvents oWinsock As MSWinsockLib.Winsock
Private mvarmServer As String
Private mvarmPort As Integer
Public Property Let mPort(ByVal vData As Integer)
mvarmPort = vData
End Property
Public Property Get mPort() As Integer
mPort = mvarmPort
End Property
Public Property Let mServer(ByVal vData As String)
mvarmServer = vData
End Property
Public Property Get mServer() As String
mServer = mvarmServer
End Property
Private Sub Class_Initialize()
Set oWinsock = New MSWinsockLib.Winsock
End Sub
Public Sub CreateConnect()
oWinsock.Connect mvarmServer, mvarmPort
End Sub
Private Sub oWinsock_Connect()
oWinsock.SendData CStr("Hello World")
oWinsock.Close
End Sub
Private Sub oWinsock_Close()
Set oWinsock = Nothing
End Sub
Private Sub oWinsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, _
ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Debug.Print Description
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|