Solved

Method 'SendData' of object 'IMSWinsockControl' failed

Posted on 2002-04-18
7
1,209 Views
Last Modified: 2013-11-13
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
Comment
Question by:jbrugman
  • 5
  • 2
7 Comments
 
LVL 4

Author Comment

by:jbrugman
ID: 6949854
ps. using windows 2000, sp2, vb6 sp 5.
0
 
LVL 8

Accepted Solution

by:
glass_cookie earned 200 total points
ID: 6955759
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
 
LVL 4

Author Comment

by:jbrugman
ID: 6958895
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
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!

 
LVL 4

Author Comment

by:jbrugman
ID: 6958899
ps.
Thanks for the examples anyway.
0
 
LVL 4

Author Comment

by:jbrugman
ID: 6958901
ps ps.
So i used a winsock.bas helper and it's class.
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6959320
Thanks for the points and grade!  : )
0
 
LVL 4

Author Comment

by:jbrugman
ID: 6959327
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question