Part two of the Winsock objects series :)

It handles incoming connections on a specific port, all you specify is a callback that handles the connection. This callback is passed a CSOCKET object, so you can use the handy GetLine method too.
Comes with a little demo program. This was used to debug it, so don't expect anything fancy (yet, anyway).

It's at the bottom of my website's download page. Website: http://www20.brinkster.com/qweerdy/
Posted on 2002-07-12 06:57:45 by Qweerdy
Hi, I really enjoyed your class implementation. :alright:

But I saw you're complaining in comments of your test app, that you cannot handle WM_DESTROY in 'Stop' Method (or destructor)of your CSERVER.

; Sadly, we can't PostQuitMessage because this runs in a different thread than our
; main messageloop. If we had a window, we'd post WM_DESTROY to the window instead.


I have a small suggestion:

In 'Init' or in Start for your CSERVER class, you can create a message-only window (like MSDN says):


"To create a message-only window, specify the HWND_MESSAGE constant or a handle to an existing message-only window in the hWndParent parameter of the CreateWindowEx function"


Possibly you could also start a standard a standard Windows message loop there, so as to have it in place.

You may still wonder what this thing is for:
You'll be able to handle WM_DESTROY sent from ServProc thread to parent process message-only Window. ;-)
To do this, it's good to save hWnd handle returned by CreateWindowEx for message-only window, as a member variable in your class.

Regards and thanks again for Your cool CSERVER and CSOCKET class.
Posted on 2002-07-12 14:23:13 by Andycar
Hmmm... interesting. I didn't know there was such a thing as a message-only window. Thanks, I'll check it out!

However, my decision to not include a window in the demo program was mainly to keep the code really simple, and including a message-only window would make it just as complex as including a regular window :( Anyway, I'll be sure to use a message-only window in my next server programs as it seems to be the best way in terms of conserving memory while at the same time doing things the preferred windows way.
Posted on 2002-07-13 03:28:07 by Qweerdy

Hmmm... interesting. I didn't know there was such a thing as a message-only window. Thanks, I'll check it out!


Well, yes, and I forgot one thing: message-only windows are ONLY 2k\XP specific.
read about it in MSDN online

Regards,
Posted on 2002-07-13 05:51:22 by Andycar