Method 'SendData' of object 'IMSWinsockControl' failed


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?
On Error GoTo errorhandler
    Dim ip As String
    ip = ""
    ' 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
Debug.Print (Err.Description)

Who is Participating?
glass_cookieConnect With a Mentor Commented:

I've got no idea about the Winsock coding with the winsock API, but, why not use the winsock control instead?  It's easier to code with it.

Anyway, here's another winsock API link for you in case the problem lies with the class after all:

A tutorial:

Description: This program will teach you how to use the winsock api's. I made this easy to understand so that anybody can use it. even beginers! isn't that crazy? *fixed, with subclassing function now!* if you like this, please vote for me! thanks!
An example:

Description: This is a great chat program that doesn't uses MsWinsock control, just API calls! It has an INI for remmembering options, home made buttons and you can add it to your systray when you don't need it (msgs from peer will popup in a very clever way). It also includes 1 simple back door (open any program on peer) (I strongly advise you to deactivated, to do so comment the !run commands in the General.Bas). Thanx to your feed back i've already...

That's it!

glass cookie : )
jbrugmanAuthor Commented:
ps. using windows 2000, sp2, vb6 sp 5.
jbrugmanAuthor Commented:
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)
    myTCPClient.TCPClient.Connect "", 1001
    ' Wait fot the server response.
    Do While (myTCPClient.TCPClient.State <> sckConnected)
    ' Send the document to the server.
    myTCPClient.TCPClient.SendData theData

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.