Y
Y
Yourmind2019-08-06 22:54:10
Python
Yourmind, 2019-08-06 22:54:10

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

6 answer(s)
K
Kirill Nesmeyanov, 2019-08-07
@SerafimArts

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.

V
Vladev, 2019-08-07
@Vladev

For such an application, any format will do. At least your own.

G
GavriKos, 2019-08-06
@GavriKos

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.

I
Ivan Shumov, 2019-08-06
@inoise

Will. Any json, and what is already in it - as you like.

S
SergJP, 2019-08-07
@SergJP

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.

P
Pardych, 2019-08-19
@Pardych

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 question

Ask a Question

731 491 924 answers to any question