Jump to content
  • Advertisement
Sign in to follow this  

Free Matching Making Service on PC?

This topic is 3047 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

Hi guys, anyone know of a free match making service on the PC? of a fixed low cost solution? Thanks! -ddn

Share this post

Link to post
Share on other sites
I'm afraid you'll have to give us a little more information than that.

I think that there are many free web-based matchmaking solutions that you might be able to use; almost all of them would run on a PC because a PC can run Apache / MySQL / PHP.

Or are you talking about UDP matchmaking for NAT punch-through?

Share this post

Link to post
Share on other sites
Btw, here you go:

from twisted.internet import reactor, protocol
from twisted.protocols import basic
import os
import sys
import time
import urllib

class Session(object):
def __init__(self, type, ip, name):
self.ip = ip
self.type = type
self.name = name
self.lasttime = time.time()

# Matcher keeps a list of sessions, and can return a list of
# sessions that match a given key and is not too old
class Matcher(object):
def __init__(self):
self.sessions = {}
def update(self, ip, type, name):
self.sessions[ip] = Session(type, ip, name)
def search(self, pattern):
now = time.time()
# do incremental clean-up of the session list, one item per query
todel = None
ret = []
for k in self.sessions.iteritems():
if k[1].lasttime > now - 120:
if pattern in k[1].type:
todel = k[0]
if todel:
del self.session[todel]
return ret

matcher = Matcher()

class Protocol(basic.LineReceiver):
def lineReceived(self, line):
global matcher
if len(line) > 512:
# don't allow ridiculous sizes
parts = line.split(" ")
ret = ["error: no command given"]
if len(parts) > 0:
ret = ["error: unknown command '%s'" %
if len(parts) == 2:
if parts[0] == 'MATCH':
q = matcher.search(urllib.unquote(parts[1]).strip())
ret = ["found %d matches" % (len(q),)]
for i in q:
ret.append("%s %s %s" % (urllib.quote(str(i.ip.host)),
urllib.quote(i.type), urllib.quote(i.name)))
elif len(parts) == 3:
if parts[0] == 'LIST':
ret = ["ok"]
for l in ret:
self.transport.write(l + "\r\n")

class Factory(protocol.ServerFactory):
protocol = Protocol

def run():
reactor.listenTCP(54321, Factory())

if __name__ == "__main__":

I just googled "python twisted tutorial" and spent 30 minutes writing some code. You run it by installing Python 2.6 and Twisted (both are free downloads), then simply:

python matcher.py

It will listen on port 54321, and accepts two kinds of commands (one line each):

LIST some-type-here some-name-here
MATCH some-substring-here

LIST puts a listing into the database under the appropriate type and name. MATCH searches for any listing that is newer than 2 minutes and contains some-substring-here within the "type" part of the listing. All arguments should be URL encoded, so spaces should become %20. Similarly, return values are also URL encoded.

Matches are returned one per line, of the form:
ip-address type-string name-string

No given command can be longer than 512 bytes.

[Edited by - hplus0603 on February 13, 2010 2:35:05 AM]

Share this post

Link to post
Share on other sites
Thanks hplus0603! Sorry for the lack of info, I'm not sure myself about the requirements. We were looking for some low cost solution for our casual games, for connecting PC <-> PC and maybe iPhone <-> PC or iPhone <-> iPhone game.

I'll look into Twisted, thanks for the heads up and the code ! :D

Thanks again!


Share this post

Link to post
Share on other sites
A question for you: What do you consider "low cost"?
And how many users do you expect to be using your application at the same time?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!