I've noticed that the bitcoin client uses sockets.

I've also seen that long polling is not only available but is also recommended.

Why? Isn't long polling far less efficient than sockets?


Don't confuse the way bitcoin clients talk to each other (peer to peer, speaking the Bitcoin protocol) with the way the bitcoin client talks to RPC clients (server to client, with bitcoind acting as an HTTP server speaking JSON-RPC).

When the bitcoin client speaks RPC, it uses HTTP. Long polling is much more efficient than HTTP without long polling, which is why long polling was created and why it's recommended if you're using RPC.

However, using RPC for miners to talk to the systems that issue them work is rapidly becoming obsolete. Stratum replaces that, and it uses a native method that's more efficient than long polling.

  • Thank-you David Schwartz! I still don't understand why sockets aren't used to push the data whenever it's available rather than inefficiently poll. Since sockets are already set up, why poll? Simply notify someone you want to subscribe to their feed. If someone disconnects, feed over. Why constantly bombard someone with polling? Thank you so much in advance! – user5107 Dec 28 '13 at 18:04
  • That's the argument for replacing RPC with stratum, which is basically what's happening. – David Schwartz Dec 28 '13 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy