1

Trying to create a reliable communication from server to client in python. the loss and delay of reception should be as low as possible. Here is my thought,

  • client notices server(DNS) when internet is up
  • server saves client IP
  • broadcast data1 to saved IPs
  • client ack msg idx to server
  • server resend until client ack (with timeout)
  • server removes IP if 3 broadcasts without ack

where data (json/df/db):

  • data1: msg idx & broadcast msg
  • data2: ip, last msg idx & connected timestamp

Now, just wanna make it simple but wish to be expandable. Is there any general practice of doing it? a backend(REST) may be necessary in future. I previously thought FCM notification might suit my need but seem not much python related resources to start up with. Please advise if the above idea is good enough.

  • Use TCP for your communication? – Some programmer dude Oct 31 '20 at 00:38
  • You could use [Socket.IO](https://python-socketio.readthedocs.io/en/latest/intro.html). Works very fast and is very reliable. – Luka Kralj Oct 31 '20 at 02:09
  • ok, TCP can simplify the steps in my flow. In general, without acc mgmt, i worry more about the packet loss / data unsync at client. so im not sure i should do this myself in python, or via api / backend with sth like push notification. – Cherrimon Shop Oct 31 '20 at 02:15
  • TCP is "reliable", meaning there should not be any loss of your data (unless the connection breaks mid-transit). It's a *streaming* protocol though, without distinct packets. If you want TCP-like reliability with datagrams use `SOCK_SEQPACKET` if supporten. – Some programmer dude Nov 02 '20 at 02:03

0 Answers0