Solved

Method 'SendData' of object 'IMSWinsockControl' failed

Posted on 2002-04-18
7
1,195 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 48
Not seen Link button 5 39
Problem to refer to value 8 48
Error with a code discussed on this page 5 14
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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

770 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