[PySide] Advice for QTcpSocket

henry.wede at yahoo.com henry.wede at yahoo.com
Mon Jan 8 19:48:06 CET 2024


Hello,
So far, my life with sockets has been very easy.  Now I have something more complicated and hope that somebody can provide some guidance.
There are thousands of positions that need to be sent to a robot controller via TCP.  The controller can buffer eight positions, so the program has to keep the buffer full.  The program can send the positions without a reply and the reply will only show up when the robot has moved to that position.  I need to add that each position has a unique sequential number.  This means that the "send" and "receive" transactions are not coupled together.  I hope that makes sense.  
My plan is to start a thread to act as a client.  Then send positions in messages.  When the thread gets a readyRead signal it would read all of the data (a reply to one of the positions) and then send a signal back to the GUI.  I will have to come up with some logic to make sure there is always eight positions sent to the robot and manage errors.  
My question:The thread would have some sort of self._socket object and a onReadReady method to read the data.  What happens if the GUI tries to send a message using MyThread_socket.send(MyMessage) while some data is being read?  Does the socket nicely wait until the data is read and then send the message or is there some sort of collision that breaks everything?  It is pretty likely that the GUI will want to send a position while the socket is reading a message

Trying to understand how to handle this "separated" send and receive concept.
Thanks for your suggestions - I hope my explanation was good enough.
Henry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20240108/bc821615/attachment.htm>


More information about the PySide mailing list