The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RedXVII on March 18, 2006, 02:16:10 AM

Title: Quick Question: whats faster?
Post by: RedXVII on March 18, 2006, 02:16:10 AM
Im making a program capable of handling alot of connections, 128+

Whats faster?

A windows message for each socket?

- OR -

One windowsmessage then a check for which socket it is?

Cheers  :U
Title: Re: Quick Question: whats faster?
Post by: realcr on March 18, 2006, 12:03:07 PM
I don't think it is a good idea to use windows messages for 128+ connections.
Maybe try using the select() function to handle connections.

realcr.
Title: Re: Quick Question: whats faster?
Post by: RedXVII on March 18, 2006, 03:11:33 PM
Me neither, i am using WSAAsyncselect. I discovered (i think) lParam is message type (FD_READ) and wParam is the socket which seems very handy =)

Will have to try this, because it means i can handle all connections with one WM. Im not sure what you mean by use select though...
Title: Re: Quick Question: whats faster?
Post by: Tedd on March 20, 2006, 10:50:22 AM
If you're using async sockets then I would go for a single WM_SOCK message, and identify the socket in there - only for program simplicity; I don't think either will actually be faster than the other. Although you could possibly try to use a lookup table rather than comparing against the list of sockets.

For your WM_SOCK message: LOWORD(lParam) = FD_READ/WRITE/etc, HIWORD(lParam) = error-code (0 if none), and wParam = socket-handle.

The "select" function allows you to check the status of many sockets all at once, so you could use this instead of setting up asyncselect.
And you can set sockets to non-blocking mode without going through asyncsel, using WSAIoctl.