Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Socket and threads

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I have a problem. I have a program using socket server communication and it works fine as long as I only have one user at time.
The flow of the program is
Receiver waiting for messenger
Sender send message, and start to wait for a response message
Receiver get message, and send a response message, start waiting for a now message.
And so on�
To day I can only send one question at time (can only have one user) but I want to have many�
Is it possible to solve with threads? And in that case, does anybody have an example of hove to solve it.
Thanks!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can solve this using threads. Basically, what you do looks something like this:

Of course, there are complications. But that's the basic idea.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your example is pretty much exactly what I'm doing right now. Creating and discarding a thread per request is easy, but not the most efficient. What's the next step up the ladder of complexity, scalability and robustness? Thread pooling?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic