Can someone please explain to me...

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Post Reply
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Can someone please explain to me...

Post by Lord Pingas »

It's a couple of questions that I just can't get my head around...

I'm getting into learning networking and I don't know how the client/server model applies to games like Runescape or WOW for instance.

Is the engine the actual client?
And what about the server, is that like another seperate application?

I have googled and found nothing about how it applies to game implementation.

Please can someone give me a detailed explanation on how this all applies to the actual implentation of online game software?
pritam
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 991
Joined: Thu Nov 13, 2008 3:16 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Amiga, PSOne, NDS
Programming Language of Choice: C++
Location: Sweden

Re: Can someone please explain to me...

Post by pritam »

A game engine can act as both a client or a server depending on how you want your game to work. The server can be a separate application running on a dedicated server for instance, but you can also have anyone starting an online game be the server of a network game session.

Network implementation for games is a science of its own, it's not something you'll learn overnight.

I think one of the cheaper (and kinda elegant) ways to offer online gaming is to get a webhost with PHP support which you have run a simple lobby script, a database of active game sessions including their respective hostnames, implement this for browsing in your game for choosing a game session to join. Have the starter of the session act as the game host/server, everyone joining a game would be a client.

I recently read this article and it's quiet interesting.

Edit: I'd recommend using TCP over UDP for a start, it's fast enough. Here's the wikipedia comparision between the two.
User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

Re: Can someone please explain to me...

Post by k1net1k »

my simplest explanation is as follows.

Client is the game (The game is a render engine and a network client built in)
Server is the server (Server rarely has any gui, and it just a network client on one side, connected to a database on the other side)

When you connect to a server you are opening a socket, and usually sending a username/password string
server responds, Auth ok - player is now free to move around etc.
You then press the up arrow on your keyboard, sending the command (player move 1px north) to the server.
Server says, thanks, updates your position in its database, and broadcasts out to other nearby players (broadcast player, moved, 1px north)

the simplest thing you could do for this would be a game of network checkers or chess.
eg player1 > move rook to D5
server updates position, and notifies player 2 > player 2's turn

as for tcp vs udp, that probably wont matter for turn based games or games with low player numbers. for a FPS or something UDP is more concise. keep in mind that UDP packets are smaller and faster, but dont have the error checking to tell the client that the server didnt get that last message. this is what happens in games where you jump from one place to the next. the packets in between arent getting there and all of a sudden you seem to get blinked to the most recent place the server has you listed at.
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Re: Can someone please explain to me...

Post by Lord Pingas »

Thank you both kindly. :)

So, for instance, the application is the client, and when you login into a game like WOW(I have never played WOW) you are inputting your password and what not into the application in which the built in client sends that information to the server(which is another application?) which checks for that information in a database and the server updates logs you on and updates your position and what not?

Is this a correct assumption?

Sorry for my noobness on the subject.
User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

Re: Can someone please explain to me...

Post by k1net1k »

you need server.exe and gameclient.exe
you give the players the game client

server.exe is setup to listen to some port (lets say port 12345)

the gameclient.exe has some built in server addresses to
1) check for updates/patches
2) get a list of servers (realms/whatever)
3) when you enter username and password, it encrypts it(hopefully) and sends it to the server it found in 2) on port 12345

server responds with a success or fail (password ok/billing ok)

client and server now have a persistent socket connection to send/receive messages

server has a list of all the players currently logged in, and common stuff like their coords and health/mana/lives etc.

once the game has loaded, and you start playing, all you are doing is sending commands to the server (eg move to 45,30) cast fireball.
server confirms that you match the player key and socket you are meant to be on, and if correct, moves the player coords on the server.
everyone on that same server within say 50yards gets a broadcast (playerX moved to 45,30 - playerX cast fireball)
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Re: Can someone please explain to me...

Post by Lord Pingas »

k1net1k wrote:you need server.exe and gameclient.exe
you give the players the game client

server.exe is setup to listen to some port (lets say port 12345)

the gameclient.exe has some built in server addresses to
1) check for updates/patches
2) get a list of servers (realms/whatever)
3) when you enter username and password, it encrypts it(hopefully) and sends it to the server it found in 2) on port 12345

server responds with a success or fail (password ok/billing ok)

client and server now have a persistent socket connection to send/receive messages

server has a list of all the players currently logged in, and common stuff like their coords and health/mana/lives etc.

once the game has loaded, and you start playing, all you are doing is sending commands to the server (eg move to 45,30) cast fireball.
server confirms that you match the player key and socket you are meant to be on, and if correct, moves the player coords on the server.
everyone on that same server within say 50yards gets a broadcast (playerX moved to 45,30 - playerX cast fireball)
I think I'm starting to get a clear understanding now you put it that way. Thanks!

Anyway do you have any links or what not to help me or others on this forum get started in networked game development?
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Can someone please explain to me...

Post by dandymcgee »

Lord Pingas wrote: I think I'm starting to get a clear understanding now you put it that way. Thanks!

Anyway do you have any links or what not to help me or others on this forum get started in networked game development?
Dunno, first google result looks pretty good to me: http://gafferongames.com/networking-for ... ogrammers/

Furthermore: Other related links
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Re: Can someone please explain to me...

Post by Lord Pingas »

dandymcgee wrote:
Lord Pingas wrote: I think I'm starting to get a clear understanding now you put it that way. Thanks!

Anyway do you have any links or what not to help me or others on this forum get started in networked game development?
Dunno, first google result looks pretty good to me: http://gafferongames.com/networking-for ... ogrammers/

Furthermore: Other related links
I did google. I was just asking incase there were any links I havent found yet. Thanks.
User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

Re: Can someone please explain to me...

Post by k1net1k »

i would suggest looking at generic tutorials for networked server/client programs. the language or commands you send between your client and server are the only things different from how IRC or WoW networking works. I mean they do some special things to make the data travel best in the smallest packet size etc. but IRC is pretty much sending plain text comands (not sure if the connection is encrypted at all).

i would google "<your language> server client tutorial"

most languages have a basic chat client, or chess client or something.

make sure you find one with both server and client code examples. remember when you make this there is no reason why you cant use your server and client on the same PC.
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Re: Can someone please explain to me...

Post by Lord Pingas »

k1net1k wrote:i would suggest looking at generic tutorials for networked server/client programs. the language or commands you send between your client and server are the only things different from how IRC or WoW networking works. I mean they do some special things to make the data travel best in the smallest packet size etc. but IRC is pretty much sending plain text comands (not sure if the connection is encrypted at all).

i would google "<your language> server client tutorial"

most languages have a basic chat client, or chess client or something.

make sure you find one with both server and client code examples. remember when you make this there is no reason why you cant use your server and client on the same PC.
Thanks! I will look into some winsock tutorials soon, but I don't think I should be worrying about that right now. I should be out there making some (single player)games!
User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

Re: Can someone please explain to me...

Post by k1net1k »

what language are you using ? i know you said winsock, but if its c# i could possibly help with some actual code examples
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Re: Can someone please explain to me...

Post by Lord Pingas »

k1net1k wrote:what language are you using ? i know you said winsock, but if its c# i could possibly help with some actual code examples
Nah, it's C/++.
User avatar
GroundUpEngine
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 835
Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK

Re: Can someone please explain to me...

Post by GroundUpEngine »

Lord Pingas wrote:
k1net1k wrote:what language are you using ? i know you said winsock, but if its c# i could possibly help with some actual code examples
Nah, it's C/++.
A few nice ones; Winsock2, SFML Network. But the concept is first more important ;)
Last edited by GroundUpEngine on Wed Mar 23, 2011 10:36 am, edited 1 time in total.
User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

Re: Can someone please explain to me...

Post by k1net1k »

ah well im sure you will work it out, its not hard. i would just suggest looking for a chat client tutorial or base to work from, and you wil lsee how its put together. the server and client were no more than 20-50 lines each for the barebones to get them talking. im not sure of the figure because i used VS and it probably added a whole lot of fluff for textboxes and buttons n stuff.
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Re: Can someone please explain to me...

Post by Lord Pingas »

Thank you all kindly. :)

I did take a while off programming but first I'm going to attempt to make some smaller games (platformers and such) and then I'll learn some sockets!

All I really need to learn really to make a smaller game is just to learn a bit more on object oriented design then I'm all set!

I'm off to go search for some object oriented design articles...

Thanks again!
Post Reply