Sign in to follow this  
Gizz

IOCP class design question...

Recommended Posts

Whenever I had to do IOCP I was always implementing my initialization stuff by hand, normally in the main / winmain function directly. I started moving my IOCP specific code in a class of it's own but since a part of the init is done in the constructor I was wondering what were you using to flag init problem in that case ? So far, I was setting a member variable to false if there was any problem in the init phase. Another solution would be to use exception. I never really used them before so I was wondering if there was a big overhead associated with them? Thanks, Gizz

Share this post


Link to post
Share on other sites
> a part of the init is done in the constructor

Constructors are generally not a good place to initialize system-dependent member variables or system states. You should use a separate 'Init()' call for that.

> I started moving my IOCP specific code in a class

http://pages.infinit.net/cbenoi1/iocp_udp.zip

-cb

Share this post


Link to post
Share on other sites
I know. But since I create the completion port without associating anything with it on the creation of my server class I though about putting it in the constructor.

I looked at your sample and saw that you are creating and associating in the same call. But you seem to have only 1 socket associated with your IOCP.

The main reason that I was creating it first then have the association done in another function is that I have more than one socket set for completion port operations.

Anyway, I will think about it some more before setting it as "final" :)

And it's a great sample you have, first one I see about IOCP with UDP. Thanks for sharing it.

Thanks,

Gizz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this