When Conenct() is called, it will attempt to conenct a socket; calling OnConnect on success, OnDisconnect() on failure, and OnTimeout() on connection timeout. Both OnTimeout() and OnDisconnect() call Connect() again, to automatically reconnect until success, causing recursion. Given enough calls, I'll get a stack overflow... anyone know of an elegant way around this, while maintaining my intended functionality?

Put a loop in Connect(). Have OnDisconnect and OnTimeout return instead of calling Connect() again, the loop in Connect() will act the same way.

You might have to add some extra logic, break the loop if calling OnConnect(), or return true or false from OnTimeout and OnDisconnect to break the loop or not. But you should be able to get it to work.

The user of the class _is_ resonsible for calling connect after disconnect; those functions are pure virtuals.

Just because they are pure virtuals does not mean you are forcing the user to call connect after disconnect. It does mean you are forcing the user to implement said functions but nothing says your base class impls cannot call pure virtual functions. So you cannot assume this type of design by looking at just the interface. The interface does not communicate this design to me in the least.

Just because they are pure virtuals does not mean you are forcing the user to call connect after disconnect. It does mean you are forcing the user to implement said functions but nothing says your base class impls cannot call pure virtual functions. So you cannot assume this type of design by looking at just the interface. The interface does not communicate this design to me in the least.

I appologize for being misleading. I'm basically trying to reinvent the old mswinsock.ocx I used when programming
in VB6 (my first language[10?]) years ago. I'm trying to encapsulate all the low-level nonsense in a class and use
the virtual functions listed in my original post as "callbacks." I was happy with the design until I came home (left it ru-
nning as a test) and found valgrind yelling at me for my poor choice.

When connecting, the "callbacks" cause trouble, because no functions are actually capable of returning. RecvLoop()
has the same problem when it calls OnDisconnect before returning.