Trying to get data from a TCP socket connection on a networked device using Python
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Cool Puzzler LoFi
--
Chapters
00:00 Question
03:06 Accepted answer (Score 1)
03:26 Thank you
--
Full question
https://stackoverflow.com/questions/6750...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #sockets #tcp
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Cool Puzzler LoFi
--
Chapters
00:00 Question
03:06 Accepted answer (Score 1)
03:26 Thank you
--
Full question
https://stackoverflow.com/questions/6750...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #sockets #tcp
#avk47
ACCEPTED ANSWER
Score 1
The devices communicate line-oriented with lines terminated by \r, so just read a whole line - replace the while True loop with
data = s.makefile(newline='\r').readline()
f.write(data) # Write data to logfile