Jump to content
  • Advertisement
Sign in to follow this  
???

command through UDP

This topic is 2189 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working a realtime mmo,
using UDP protocol to send command and MySQL as my database.
However, I have some question about login system.
Since UDP doesn't create a static channel,
I have to send the command with user information to identify who send it.
Of course I won't send the username and password in each UDP command,
The question is, how do I identify that who send the command to server?

Share this post


Link to post
Share on other sites
Advertisement
use ip address/port to identify clients. additionally you can assign a random session id to the user which he has to send with every packet

Share this post


Link to post
Share on other sites

use ip address/port to identify clients. additionally you can assign a random session id to the user which he has to send with every packet

Good solution!
However, is that means if I want to allow a user to multi-login with the same IP, I can't fix the client port?
Is a MMORPG game client using random port normal?
Any pros and cons?
Thank you!

Share this post


Link to post
Share on other sites

Almost all clients use random ports.




[quote name='Madhed' timestamp='1342899335' post='4961748']
use ip address/port to identify clients. additionally you can assign a random session id to the user which he has to send with every packet

Good solution!
However, is that means if I want to allow a user to multi-login with the same IP, I can't fix the client port?
Is a MMORPG game client using random port normal?
Any pros and cons?
Thank you!
[/quote]

I can't think of a single gameclient that specifies the port it uses to recieve data, you should not use a random port though.
You should let the OS assign a free port(The port you get from the OS might seem random but there is usually a system to it) to your outgoing connections (there might be other applications using sockets on the users machine aswell and any attempt from your appilications side to force a specific portnumber might fail miserably).

Normally when you open an outgoing connection you only specify which port on the target machine you want to connect to and the OS assigns a port on which you can retrieve data using the same socket, if you open a second socket to retrieve data on a static port you will not only risk causing conflicts with other software, you will also break the functionality of most NAT routers.

With UDP you simply create your socket without specifying a port and use sento / recvfrom , (The server should specify a static port for its socket though) Edited by SimonForsman

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!