PDA

View Full Version : TCP server client threads



jmsbc
17th November 2009, 20:10
Hello,

I have a question regarding TCP server client connections:

I am writing a GUI program that constantly receives data from an external source on a socket connection. The GUI itself lets the user configure some settings that will be sent to that external source on the same socket connection. (So both the server and client send and receive data to each other independently)

Currently I have a TCPServer running from the GUI to listen for the incomingConnection from the external source. After the connection gets made and I get to the incomingConnection(int) slot of the TcpServer, should I create a new thread for reading and a new thread for writing? How would I make sure that a write does not occur on that socket at the same time from both the client and the server?


I tried looking at the fortune network example but that only does a read from the client side and a write from the server side. Are there any other examples that are similar to this situation?

Thank you.