Link to home
Start Free TrialLog in
Avatar of jbrugman
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.state <> 0) Then myTCPClient.TCPClient.SocketClose
    Call myTCPClient.TCPClient.ClientConnect(ip, 1001)
    If myTCPClient.TCPClient.state = 6 Then Form1.Text1.Text = "open..."
   
    ' DoEvents
   
    ' Send the data to the server.
    myTCPClient.TCPClient.SendData sfile + vbCrLf
   
    myTCPClient.TCPClient.SocketClose
   
errorhandler:
Debug.Print (Err.Description)

Avatar of jbrugman
jbrugman

ASKER

ps. using windows 2000, sp2, vb6 sp 5.
ASKER CERTIFIED SOLUTION
Avatar of glass_cookie
glass_cookie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.State <> sckClosed)
        DoEvents
    Loop
    myTCPClient.TCPClient.Connect "127.0.0.1", 1001
   
    ' Wait fot the server response.
    Do While (myTCPClient.TCPClient.State <> sckConnected)
        DoEvents
    Loop
   
    ' Send the document to the server.
    myTCPClient.TCPClient.SendData theData

Justus
ps.
Thanks for the examples anyway.
ps ps.
So i used a winsock.bas helper and it's class.
Thanks for the points and grade!  : )
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 :)