Answer the question
In order to leave comments, you need to log in
What format for transferring data (objects / lists) should be used when transferring via socket?
I want to create an application (checkers game)
The server works on a computer (then host it on some kind of aws)
I have all the logic in it. It is written in python
. And I want to make clients for mobile applications (android)
and since I have never been involved in mobile development and while I am writing a server, I need to understand what format I can receive via the socket?
That is, if I had 2 applications in python, then I would send everything by converting all my objects using the pickle library. (I operate mainly with lists and objects built on it)
But right now I don’t know from which format I can get my lists / objects in the right form? Will the necessary libraries be in jap on the client side?
Answer the question
In order to leave comments, you need to log in
If you need the simplest option, then yes, as correctly stated above: JSON.
You can also take BSON, or Msgpack. They will be more efficient, but harder to debug.
Also, as the most correct option, I would suggest Protobuf. But it should be borne in mind that it is more complicated than the options described above.
In any - the socket operates with bytes.
It is possible to transfer something low-level, and wrap it in json. The latter can be a little overhead, but it is easy and fast.
When I wrote a mobile application and the server for it, I just came up with my own data exchange format.
I just separated the fields with asterisks: *imei*code*parameter*
Common formats (XML, JSON) are redundant for simple tasks.
https://github.com/irmen/Pyrolite
is
there
https://github.com/irmen/Pyrolite/blob/master/java...
and
https://github.com/irmen/Pyrolite/blob/ master / java ...
in general, I just became interested and I googled, I serialize-deserialize byte arrays with my hands (they come from a piece of iron via bluetooth) - not a very fun activity
, there can still be problems with the protocol, look here for examples:
https://stackoverflow.com/questions/21794750/read-...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question