I'm making a multiplayer mode for a game I developed, and it works over UDP.
What I need now is a server to let a player know another player, and send each one the other's IP.
I own a VPS that I'm currently using to host a few websites, so I guess I can use it for this purpose too.

I would choose Python as a language to build it. But I don't know where to start...
Should I make it on HTTP or TCP?
Is there any library I can use to simplify the work?
Or any example of something similar?

Any help will be appreciated.


2 Answers 2


First of all, HTTP and TCP are protocols for entirely different purposes.

TCP is a transport layer protocol designed to transport information inside a network from one end to the other in a reliable way.

HTTP is an application-layer protocol designed to get application-specific information across a given connection. It does not care about how the information is transported (other than the fact that it uses TCP to transport data), it just cares about how the information is formatted.

Asking "Should I use TCP or HTTP" is like asking "Should I use a hammer or nails to put that picture on the wall?".

As for your problem: I would strongly suggest that you simply build your own protocol and use it. It's not that hard. You get your connection up (usually through UDP, but since latency won't be an issue for your handshake server, TCP will be fine and easier to handle, too) and literally just send a bunch of text messages across the connection.

For example, a basic network protocol for your needs could look like this:

-Client sends "HELLO, I'M [YOUR NAME]"

-Server registers name.

-Client sends "GIVE LIST" to server

-Server sends the names of a whole bunch of players

After client selects server in your GUI or whatever you have set up:

-Client requests IP address of player by sending "GET [PLAYERNAME]"

-Server sends IP address of player

-Client connects

It's literally as simple as that. Thanks to TCP your server will know who sent the requests and can answer accordingly, and TCP also handles packet transfer, so you don't have to worry about ACKing and such.

Of course, it is not that simple. If your server would run like that, it would be pretty vulnerable to distributed denial of service attacks (although your v-server provider might already take care of that for you) and there are of course other issues, like player identification (you might not want anyone to log onto your server), traffic minimization (making the messages a little more cryptic in order to send a few characters less per message) and so forth. But you should be able to figure out the rest.

If you're asking about how to transfer stuff across a network in general, you should google "sockets" in addition to the name of the programming language that you're using.


Because this server will be handling relatively little traffic and only has to be talked to to set up a game, it probably wouldn't be terrible to make it an HTTP-based service. I would tend to advise rolling your own application-level protocol over TCP anyway, though, if only because it's of fairly major concern here whether a client is still there and waiting for a game, and HTTP complicates that considerably with its pesky statelessness.

As far as examples go, here, have some pretty good, well-commented example code for a general network service daemon in Python that you can start building from.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .