I want to create a simple game that can be played with one to two player. I plan on using TCP sockets, Farseer Physics, XNA, a BinaryFormater and a Memorystream.

as far as i know i can't do the physics on both clients, or you'll end up with everything out of sync. So my Idea was to do the physics on the host side then send the Farseer World data to the other client, however it is un-serializable and I also realized this was a lot of data to send every tick.

I could just send the players movements back to the server and send a Texture2D to the client to be drawn, however a Texture2D is un-serializable as well. it has dawned on me i must be doing this completely wrong.

But this is how i am attempting to send the data:

class ServerData
    public Texture2D Test;

    public Vector2 Test2;

    static void SendData()
        byte[] DataBuffer = null;

        MemoryStream stream = new MemoryStream();
        BinaryFormatter formatter = new BinaryFormatter();
        NetworkStream netStream = PlayerOneSocket.GetStream();

        ServerData ServerDataToSend = new ServerData();

        formatter.Serialize(stream, ServerDataToSend);
        DataBuffer = stream.ToArray();
        netStream.Write(DataBuffer, 0, DataBuffer.Length);

what am i doing wrong or how do i do it right.

I've done basic server stuff before with custom classes and serialization, I'm just at a loss on how to make a multiplayer game.

Thanks for the help


1 Answer 1


Send logical data, not presentation. Most games will never send graphics or textures to other systems during gameplay. Each system should already have all the resources it needs to render the events; you just send information about which events have taken place.

  • \$\begingroup\$ thanks, i actually just woke up about an hour ago thinking the same thing. But having clarification is really helpful :) \$\endgroup\$
    – Dusty
    Commented May 28, 2012 at 11:59

You must log in to answer this question.

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