I'm programming a simple network chat with a Python server and a Java client. But one question came into my mind:
Which "network protocol" should I use for communication? There are some possibilities for me:
So what is the best practice for this? Are there other alternatives?
Check JSON. It is compatible accross many languages (Python and Java included), and it is human readable. http://www.json.org/
If you plan to do Web development, and plan to use Javascript, then JSON might be a good choice as it was originally designed for Javascript.
Moreover compared to YAML, using JSON in Python is as easy as writing: import json
(it is part of the standard library).
You may have a look at the following page, comparing XML, JSON, and YAML. It seems they are differences in terms of encoding delay and memory used, that might guide your choice.
It may be a little bit heavyweight for your needs, but have you considered implementing XMPP protocol for your chat client?
If you do that, then your system could interoperate with Google Talk, Jabber, iChat, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With