// JP opened flex table

Click to See Complete Forum and Search --> : Network programming - please help


gambiting
December 30th, 2007, 04:16 PM
Hi! I'm programming my own IM,using QT and linux Socket libriary ( http://www.alhem.net/Sockets/ ).As for now I have achieved:
-Working QT app,with one thread that runs window,and other one for network
-Echo server - it receives message from qt app and echoes it back.It also spawns new thread for each new connection.

My problem is,that I want to send message to all connected clients simultaniously - it looks like that:
I run my server program.Client number one connects.Client number two connects. Now I want to send client two message that client one send to server.I don't know how to do it as every connection's thread is set to listening - it activates only when it receives data(and echoes it back,then goes to listening again),so when I receive message in thread number one,I don't know how to send it to thread number two.Could anyone explain it to me?Is listening to incoming and outgoing connections possible?If yes then how?If not how can I do what I described?Thanks

upredsun
January 2nd, 2008, 12:22 AM
i think you can just use one thread to listen on your server socket and when there are connection incoming,the listen thread will create a work thread for the new incoming connection.

about the work thread,you can make a long term session with your client.by this way,the work thread can receive or send data to your corresponding client.when the client close the connection,the work thread can quit.

//JP added flex table