IOCP class design question...
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
> 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
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
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement