Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Winsock.ocx used in class will not raise DataArrival events - why?

Posted on 2003-03-18
Medium Priority
Last Modified: 2013-12-26
Using VB6.0 sp5 on NT4.0.

I have a class with the following;
Private WithEvents mSocket As Winsock

But the DataArrival Event is not firing within the class.

[Object Browser definition:
 Event DataArrival(bytesTotal As Long)
 Default member of MSWinsockLib.Winsock
 Occurs when data has been received from the remote computer]

Initially I thought it might be due to no actual data having arrived (!). However, I know that it is being sent from the host machine. And more importantly, a third party socket analysing tool (TracePlus/Winsock from www.sstinc.com) allows me to view the expected data arrive on my local buffer, yet still no event is raised within VB.

The SendProgress event is working, as is the Error event. The Host machine is using third party software to actually return the data, but we have successfully connected & I can send data to it which it successfully receives & processes.

It might be worth noting that 1. the control is not on a form & is being instatiated within the class & 2. the use of the Winsock.ocx is to replace old API calls which worked okay, but obviously don't map to the winsock exactly.

(N.b. I would give more points but I've just signed up & 75 doesn't go very far!!)

Question by:SimonWray

Accepted Solution

y2ksw earned 300 total points
ID: 8220283
The OCX *must* me placed on a form, even if it is a dummy form (invisible). From then on it will work. I've had the same problem with a web server. Classes are nice, but won't solve all problems :-)

Expert Comment

ID: 9053420
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept y2ksw's comment as Answer

Please leave any comments here within the next seven days.


Cleanup Volunteer

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

572 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