Search Unity

backend server - python and UDP/TCP

Discussion in 'Multiplayer' started by tomcat, Oct 14, 2009.

  1. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Hi,

    I am working on a game as part my studies and have to link to scientific libraries which are written in python. See message http://forum.unity3d.com/viewtopic.php?t=33837.

    I like to know how can I connect my game (unity front end) to a back end which is in python.

    Somebody suggested UDP, but not clear how I can create UDP packets (TCP is even better) in the client and send it across.

    Has anybody done this?
    Does anybody know how this is supported in unity and where I can find some docs?
     
  2. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Do you know python?
    Are you running the simulation on Windows or the Mac?
     
  3. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Yes, I know python.

    My client is running in a browser, but my server is windows, although I like to run it on a linux server like ubuntu.
     
  4. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Google up iron python, as far as I know, the version of mono that unity is using works with iron python, so you should be able to use it, built in tcp/ip networking commands with unity and be able to use the script. Without knowing or getting ahold of the python files and documentation, can't do to much more to help.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Unity has no DLR integrated, as such you can't use IronPython / IronRuby

    But you also don't need it as server and client are distinct.

    On the Unity end you would use the System.Net namespace and the corresponding socket for the networking protocol of your choice.

    On the other end, python would handle it all for the server.
     
  6. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Thanks guys. I am now working on a simple udp client using the System.Net library. As UDP by its nature is unreliable, I am also looking to find out how to make it reliable.

    tomcat
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Check out Enet / lidgren
    both come with sources and show you ways to recreate reliability with UDP.

    Generally the idea is just using the same ack - nack messaging as TCP does internally on its own.
     
  8. tomcat

    tomcat

    Joined:
    Nov 16, 2008
    Posts:
    66
    Thanks. Thats where I am looking now.

    tomcat