 <p>You should send metadata with your data so the server understands what it needs to do. This means you are defining the protocol to which all clients and servers need to support. For these two different cases (either it is a plain chat message or some command the server needs to execute) you can roll your own protocol. But in software development things always start small and grow large (rapidly).</p> <p>You might want to look into something like XMPP which is a XML based chat message protocol. <a href="http://xmpp.org/xmpp-protocols/" rel="nofollow">http://xmpp.org/xmpp-protocols/</a></p>