Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1264
  • Last Modified:

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)

0
jbrugman
Asked:
jbrugman
  • 5
  • 2
1 Solution
 
jbrugmanAuthor Commented:
ps. using windows 2000, sp2, vb6 sp 5.
0
 
glass_cookieCommented:
Hi!

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:

Download...
http://www.planetsourcecode.com/vb/scripts/ShowZip.asp?lngWId=1&lngCodeId=7440&strZipAccessCode=ODE%5F74407742
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:

Download...
http://www.planetsourcecode.com/vb/scripts/ShowZip.asp?lngWId=1&lngCodeId=25603&strZipAccessCode=hatB256037872
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 : )
0
 
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)
        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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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