Valhalla Legends Forums Archive | C/C++ Programming | Socket events in mfc?

AuthorMessageTime
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.
November 3, 2008, 6:41 AM
Myndfyr
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.
November 3, 2008, 11:00 AM

Search