First of all i want to state that i´m a noob to this, so this may be (partially) wrong and i might use wrong words.
To make a Server for more than one connection,
you should seperate the operations for the different sockets,
because right now the script does this:
1. the server initalizes the winsock with
WSAStartup
2. the creates a socket (the first socket of two) with
socket
3. the server binds itself to the socket and tells the
socket that it is listening with
bind
listen
4. the server tells the socket to send WindowsMessages on Received Data
(this is optional, because you can just question the socket with a
looped receive instead) with
WSAAsyncSelect
5. the server accepts an incoming connection blind
(without knowing if there really one) in a loop
until it returnes a valid socket ID with
accept
if accept returns a valid socket id, it means that
there realy was an incomming connection, that could be accepted, and
winsock has automacaly created a new socket with the
same properties as the first socket
(not only same type and ip, but also
if it is sending Windows Messages when WSAAsyncSelect was called)
[My Loop stopps after one accepted connection]
6. the server sends and receives data through the new socket with
send
recv
The send and receive command have to work with the new socket,
that was created by winsock, because the incoming connection will
talk to this socket and not the one that was monitoring for the incoming connection.
To handle more than one connection you will first have make the
accept loop (Nr.6)keep going after the first accepted connection.
You will hopefully get a socket for each incoming connection.
The tricky part will be to handle all the sockets. The MSDN recommends
to start a new thread for each socket.
(That would probably mean to start
another script with the socket id as commandline parameter,
or using WindowsMessages for the transfer of the socket id.
The new script will maybe need to init Winsock itself, but i don´t know?
If you only have limited demands, you can also use the function
that is called by the WindowsMessages received from the socket,
to not only receive but also send some data, but i´m not shure if there
will be "collision" problems.
Or you don´t tell the winsock to send WindowsMessages at all(Nr.4),
and question and respond to all the open sockets
one after another in a loop.