Jump to content

Compressing JSON transmitted by a socket


NotionCommotion

Recommended Posts

I wish to compress JSON-RPC messages which are being transferred by a socket.

Looks like using http://php.net/manual/en/intro.zlib.php won't work with sockets.  Correct?

Should one just call the appropriate function before sending and before reading the content?  How do I determine which function to use?

  • gzcompress/gzuncompress
  • gzdeflate/gzinflate
  • gzencode/gzdecode
  • zlib_encode/zlib_decode
Link to comment
Share on other sites

Haven't we gone over this before?

You can use whichever one you want. *compress does ZLIB, *flate uses DEFLATE, gz*code uses GZIP with the header, zlib_*code is general-purpose.

Consider what it means to have a header, then choose between the other two according to whatever other things you can think of that could possibly, and if you're still unsure then flip a coin.

Link to comment
Share on other sites

10 hours ago, requinix said:

Haven't we gone over this before?

You can use whichever one you want. *compress does ZLIB, *flate uses DEFLATE, gz*code uses GZIP with the header, zlib_*code is general-purpose.

Consider what it means to have a header, then choose between the other two according to whatever other things you can think of that could possibly, and if you're still unsure then flip a coin.

Yeah, we discussed it here where you recommended using gzip/zlib encoding over CBOR or MassagePack.

 I thought there was more discussion than this but couldn't find it, but just did and apologize for the redundancy.

 Regarding your comment "Consider what it means to have a header", this is just related to error handling, true?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.