rework tcp server

motivation: a thread creating a lot of messages like a polling loop
with very short polling frequency or a fast polling connection might
monopolize the output of message over receiving new messages.
In addition, the current design has a latency of 0.3 sec for the
output of asynchronous replies.

Anyway, the output queue is just extending the network output buffer,
which is usally big enough.

- change the name of 'queue_async_reply' to 'send_reply'.
  This method anyway was not only used for async replies.

- send_reply is directly sending the reply instead of putting into the
  queue. It will slow down the calling thread, if the output buffer
  is full, which is desired behaviour.

Change-Id: I305669be2f7c027355b43421432f32be9c166ed4
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/23119
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2020-05-20 15:20:19 +02:00
parent 31ae0a88b4
commit f7a6ba8b5b
3 changed files with 35 additions and 54 deletions

View File

@ -149,6 +149,7 @@ class AsynTcp(AsynConn):
def send(self, data):
"""send data (bytes!)"""
# remark: will raise socket.timeout when output buffer is full and blocked for 1 sec
self.connection.sendall(data)
def flush_recv(self):