• Welcome to Valhalla Legends Archive.
 

Socket events in mfc?

Started by iNsaNe, November 03, 2008, 12:41 AM

Previous topic - Next topic

iNsaNe

I've recently started a new bot project in mfc (I've never used mfc before) but I'm stuck with the socket connections. I'm using mswinsck.ocx in my app like in visual basic. I'm not sure how to send messages to the winsock control to connect and receive data and etc.

Any help or suggestions? I would really appreciate it I've been searching all over but haven't found anything helpful.

MyndFyre

First, I think it bears asking: why?  As if working with COM isn't enough of a headache, you're going to go after a control specifically designed to be used in Visual Basic?  Just use the sockets API, man!

If you want to listen to events, you'll need to do the standard COM plumbing for doing so within C++.  Specifically, you'll need to create an events sink class that implements the events sink interface (the OCX is evidently so old that I can't find documentation to point you towards, so I can't give you specifics, unfortunately), and then pass that into a property on the control object.

If you're having trouble just creating an instance, you'll have to get a pointer to the control via CoCreateInstance and then cast it back to a pointer type of the interface exported by the OCX.  Again, I'm not sure what the API is.  However, I'm fairly certain that there isn't a C++ header file for this OCX out there, which means that you're going to have a lot of work to do by hand.

I strongly recommend going with the native Windows API in regards to handling sockets.  You're going to have a lot less of a headache.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.