Solved

Method 'SendData' of object 'IMSWinsockControl' failed

Posted on 2002-04-18
7
1,186 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 78
wordmultiple challenge 12 118
Can we place a tooltip on the actual vb6 form 5 35
VB 6 error 5 in windows 10 but not in XP 7 43
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now