What is the best way for a server to identify a client?

Started by
24 comments, last by micah_death 17 years, 11 months ago
What is the best way for a server to identify a client? a) When client first logs into the server, the server creates a temporary ID and sends it back to the client. This temporary ID is now both on the server and client. Now when the client sends packets to the server this temporary ID will be in every packet so the server will know where this packet came from. OR b) When client first logs into the server, the server obtains the IP address of the client. Now when the client sends packets to the server, the server will know it is user X of IP address x.x.x.x because the server identifies the user by their IP address. OR C) implement both solutions OR D) other Please offer advice! :)
Advertisement
I prefer to use the MAC Address from the client. If you have your program get the network hardware address you can use it as a unique ID for them. It will not change if they have to do a reboot for what ever reason.

Just my 2 cents.

theTroll
... or maybe let the user login to an account on the server?
Store each user under a specific id in the server and then use that
id (which will always be unique :)
visit my website at www.kalmiya.com
If it's a TCP connection, just use the socket. If it's UDP, use the sockaddr struct which contains the ip/port.
Good to identify computers by mac addresses, and identifying by just IP has a problem with those behind a nat. identifying by IP + port would probobly work pretty nicely.

Problem with using a unique ID though, is you have to make sure it's different than the actual object ID [the one you use to keep track of things in the game engine,the one you'll probably send out to all the other clients], or you may find yourself in a position of having players sending packets on the behalf of other players, or even one player playing as an entire group of characters. Might be a good idea to demand a mac address upfront durring login, match it with the ip/port, use the ip/port as the actual tracker data, and for each log in, check to make sure the mac address isn't already in the table [so you don't have the problem of a single computer logging in with a bunch of characters.. unless you don't mind that kinda thing]
Does the client software obtain the mac address then send it to the server?

or

Does the server determine the clients mac address when the client tries to login (via tcp)

I am using TCP.
The clinet determines its MAC and then durring the connection process sends the MAC to the server, it then tags all of it's traffic with the MAC address..

theTroll
Quote:Original post by RDragon1
If it's a TCP connection, just use the socket. If it's UDP, use the sockaddr struct which contains the ip/port.


'nuff said.
This space for rent.
I would use IP, port, and unique ID assigned by the server.
IP & port guarantee that you are sending to the real client.
unique ID guarantess that you are recieving from the real client.

A client can easily send a MAC address of another player. Thus if you only identify by MAC, any malicious player can easily tap into another players game.
How can you get the MAC address of another player? I really don't think that unless you hand to be on the same network that it is possible. MAC address are layer 2 so unless you are on the physical network you should not be able to see another persons MAC address..

theTroll

This topic is closed to new replies.

Advertisement