'Python socket not reading multiple lines
I have below python code snippet that acts as TCP server. The problem is when I try to send multiple lines from client one by one I am receiving only the first line and after that TCP server is sending RST(I verified this in wireshark) whereas if I send multiple lines at one shot I am receiving all of them.
class SyslogTCPHandler(socketserver.BaseRequestHandler):
def handle(self):
total_data = []
while True:
data = self.request.recv(8192).strip().decode("ascii")
if not data:
break
print("LOG: {}".format(data))
def open_tcp_syslog_server():
try:
server = socketserver.TCPServer(('0.0.0.0', 5143), SyslogTCPHandler)
server.serve_forever(poll_interval=1)
except (IOError, SystemExit):
raise
except KeyboardInterrupt:
logger.info ("Crtl+C Pressed. Shutting down.")
open_tcp_syslog_server()
Below is the TCP client that I am using,

If I uncheck "Send One message per Line Feed" then it works fine. One more thing to note is that if I change the encoding to "UTF8" from ASCII then its working fine.
Any idea on how what's happening?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
