jbrugman
asked on
Method 'SendData' of object 'IMSWinsockControl' failed
Hi.
I use a std. class module winsock.cls (from hector), together with the reference to MSWINSCK.OCX
Now i've written a client with the following code,
ps. the error i get is the same as the question,
when i first start the connection in another function, like in loading the form, it works fine.
At inserting a doevents, it works one time, using sleep doesn't make a difference.
Any ideas?
code:
On Error GoTo errorhandler
Dim ip As String
ip = "127.0.0.1"
' Make the connection to the server.
If (myTCPClient.TCPClient.sta te <> 0) Then myTCPClient.TCPClient.Sock etClose
Call myTCPClient.TCPClient.Clie ntConnect( ip, 1001)
If myTCPClient.TCPClient.stat e = 6 Then Form1.Text1.Text = "open..."
' DoEvents
' Send the data to the server.
myTCPClient.TCPClient.Send Data sfile + vbCrLf
myTCPClient.TCPClient.Sock etClose
errorhandler:
Debug.Print (Err.Description)
I use a std. class module winsock.cls (from hector), together with the reference to MSWINSCK.OCX
Now i've written a client with the following code,
ps. the error i get is the same as the question,
when i first start the connection in another function, like in loading the form, it works fine.
At inserting a doevents, it works one time, using sleep doesn't make a difference.
Any ideas?
code:
On Error GoTo errorhandler
Dim ip As String
ip = "127.0.0.1"
' Make the connection to the server.
If (myTCPClient.TCPClient.sta
Call myTCPClient.TCPClient.Clie
If myTCPClient.TCPClient.stat
' DoEvents
' Send the data to the server.
myTCPClient.TCPClient.Send
myTCPClient.TCPClient.Sock
errorhandler:
Debug.Print (Err.Description)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I alreaddy found the answer.
Winsock api can not be used, becouse in some cases it deletes / corrupts your stack, and even the following solution will not work then.
Ps. winsock also uses a form, and for an activex dll, i have no use for them.
Anyway, for the record:
' Open the connection to the server.
Do While (myTCPClient.TCPClient.Sta te <> sckClosed)
DoEvents
Loop
myTCPClient.TCPClient.Conn ect "127.0.0.1", 1001
' Wait fot the server response.
Do While (myTCPClient.TCPClient.Sta te <> sckConnected)
DoEvents
Loop
' Send the document to the server.
myTCPClient.TCPClient.Send Data theData
Justus
Winsock api can not be used, becouse in some cases it deletes / corrupts your stack, and even the following solution will not work then.
Ps. winsock also uses a form, and for an activex dll, i have no use for them.
Anyway, for the record:
' Open the connection to the server.
Do While (myTCPClient.TCPClient.Sta
DoEvents
Loop
myTCPClient.TCPClient.Conn
' Wait fot the server response.
Do While (myTCPClient.TCPClient.Sta
DoEvents
Loop
' Send the document to the server.
myTCPClient.TCPClient.Send
Justus
ASKER
ps.
Thanks for the examples anyway.
Thanks for the examples anyway.
ASKER
ps ps.
So i used a winsock.bas helper and it's class.
So i used a winsock.bas helper and it's class.
Thanks for the points and grade! : )
ASKER
Well, you're the only one who gave some ideas, next i think it's usefull to paq these kind of questions.
Glad you're happy with them :)
Glad you're happy with them :)
ASKER