XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

Recommendation for a Windows game, to use XNA Networking or some other network library?

Last post 7/25/2009 12:00 AM by ninpomaniac. 5 replies.
  • 7/17/2009 1:19 AM

    Recommendation for a Windows game, to use XNA Networking or some other network library?

    Hey guys,

    I'm porting over a Windows game from C++ to XNA / C#, and am ready to add networking support.  I already have a client and server system written in C++ already, so I guess what I'd like to know is whether using XNA's networking is going to be more of a kludge than converting my code to C#.  My target platform is Windows only, and my multiplayer mode will only be between two players with no dedicated server ( one player will host ).  I have no need for MS lobby servers or other infrastructure, just the ability to send UDP between systems.

    I have also read that the end user will need to install some extra junk on their machine before they can use XNA networking... is this true? 

    Also, do I need a Live membership if I just want to connect peer-to-peer across the Internet?  I read something about System.Link only supporting local LAN connectivity.

    Any feedback will be appreciated.

    Thanks!
  • 7/17/2009 1:36 AM In reply to

    Re: Recommendation for a Windows game, to use XNA Networking or some other network library?

    You are not allowed to redistribute the Live! networking on Windows, so using Xna networking for a Windows game is not possible.

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 7/17/2009 2:30 AM In reply to

    Re: Recommendation for a Windows game, to use XNA Networking or some other network library?

    I've had great experiences using ENet for UDP networking in the past. It's a C library, so you'll need to do some P/Invoking, but it should be extremely easy to integrate. You might be able to find a .NET wrapper if you dig around.
    Kevin Gadd, Squared Interactive
    Development Blog | Twitter
    Help playtest my game, Inferus!
  • 7/17/2009 2:30 AM In reply to

    Re: Recommendation for a Windows game, to use XNA Networking or some other network library?

    Thanks guys,

    It looks like sockets in C# is pretty straightforward, and I just learned how to make a thread, so it looks like I'll port my network code after all.

    I found this example http://www.java2s.com/Tutorial/CSharp/0580__Network/SimpleUdpClientsendandreceive.htm

    doesn't seem near as convoluted as the C++ version.  :)
  • 7/17/2009 4:19 PM In reply to

    Re: Recommendation for a Windows game, to use XNA Networking or some other network library?

    You don't need a thread.

    Create a UdpClient. Call BeginReceive() on it, passing in a completion function. If BeginReceive returns a result that completed asynchronously, simply spin on BeginReceive() and dispatch the data until there is no more data to send. I've never seen BeginReceive complete synchronously, though.
    In the completion function, call EndReceive(), and if it did not complete synchronously, issue another BeginReceive(). Then dispatch the data (byte array) that you received.

    For sending, call BeginSend() with a completion function when you have a full packet to send; the completion function doesn't need to do much. In general, you'll want to use a queue of messages, and glom them all together into a single packet to send something like 20 times a second.

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 7/25/2009 12:00 AM In reply to

    Re: Recommendation for a Windows game, to use XNA Networking or some other network library?

    Is this something they are planning to address? I am building a game with networking support and had some testers (friends) install VC# and XNA Game Developer Studio but it crashes when they login. Could that be because they are not Creators Club members? Thanks for any help,
    ~/jt
Page 1 of 1 (6 items) Previous Next