2

Is it possible to write a simple python script which handles real-time server pushing of data back to the client when data is available?

oshirowanen
  • 15,297
  • 82
  • 198
  • 350

1 Answers1

2

"Yes, but":

You can keep the connection between the client and server live; but this can take significantly more server resources.

Edit: If you want to do this, see

You can have the client register an IP address which the server can contact, but you will run into a huge amount of trouble with client-side firewalls.

Or you can just do what most services do, and have the client poll the server occasionally.

Community
  • 1
  • 1
Hugh Bothwell
  • 55,315
  • 8
  • 84
  • 99
  • Is it not possible to use the standard http port, avoiding all firewall issues? – oshirowanen Dec 07 '10 at 13:48
  • @oshirowanen: For the client contacting the server, yes. For the server contacting the client, almost certainly no. **You may be able to work around this if you are on some sort of internal (ie corporate) network; but for the general internet case, you probably don't want to go there. – Hugh Bothwell Dec 07 '10 at 13:54
  • So if the client contacts the server via http, and the server keeps the connection open, can python not be used to push data back via the same http connection when data is available? – oshirowanen Dec 07 '10 at 14:13
  • 1
    For your first solution, keeping the connection alive which was started by the client, websync is written in c# and was tested on a $500 desktop which was able to handle 30,000 concurrent connections. How many connections would python be able to handle? – oshirowanen Dec 07 '10 at 14:26
  • @oshirowanen: "it depends" on exactly how you use it, but it looks like either [Diesel:http://dieselweb.org/] or [Tornado:http://www.tornadoweb.org/] will support something like 5000-8000 concurrent connections on a reasonably beefy dedicated server. – Hugh Bothwell Dec 07 '10 at 15:37