Re: How to make game server?
I use sockets not Winsock to network games in VB, but the principle is the same.
Server:
Create a listening socket on a port
Loop{
Accept a client
Create a new inputThread to deal with this client's input
Create a new outputThread to deal with this client's input
}
Server-inputThread
Loop{
Get client input using the accepted client socket
process the input
}
Server-outputThread
Loop{
sendDisplay/data required to client
}
Client
Create a new socket using the server's ip+port
Create a new inputThread to handle incoming data from the server
Loop{
Get keypress
send keypress to server using socket
}
Client - inputThread
loop{
recieve data from the server
update display
}
At least this is my way of doing it, generally uses 2n +1 threads on the server (n is number of clients) and 2 threads on each client.
I've got an example of both a chat room (which is pretty easy to understand) and an old nethack (top down, console (ASCII characters representing things)) game/RPG which is a bit more complex if you want them.