I've look all over the internet but all the tutorials I've come across
are for chat servers which I can't seem to relate to.
There's no difference between a chat server and game server regarding the use of select.select
.
I was just wondering how I'd let multiple clients connect to my server
through select.select.
You'd pass the server socket (which you called listen
on) in the rlist argument to select
; if after return from select
the server socket is in the first list (the objects that are ready for reading) of the returned triple of lists, you'd call accept
on the server socket and thus get the new client socket, which you'd append to the rlist in subsequent select
calls.
And also how would I send/receive data to/from individual clients
using select.select
If after return from select
a client socket is in the first list (the objects that are ready for reading) of the returned triple of lists, you'd receive data by calling recv
on that client socket.
You don't need to use select
for writing; you'd just send data by calling send
.
See the question "Handle multiple requests with select" for an example server.