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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.