• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1285
  • Last Modified:

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)

  • 5
  • 2
1 Solution
jbrugmanAuthor Commented:
ps. using windows 2000, sp2, vb6 sp 5.

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:
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now