multiple clients - single server application,
each as separate processes
Selçuk Cihan
selcukcihan at gmail.com
Sat Feb 16 03:44:22 PST 2008
On Feb 16, 2008 11:47 AM, Lukasz Michalski <lm at zork.pl> wrote:
> See samples/sockets/baseclient.cpp and baseserver.cpp for example of
> multithreaded server and client.
Thanks very much.
Now, i think it makes sense to have two threads(one listener and one
sender) corresponding to each client(at both server side and client
side application). Listener should always listen and the application
does not know when to listen; but it knows when to send something, so
i thought sender would be implemented in Listener. However, then when
the application will write to a socket, the GUI would block.(i am
using wxSOCKET_WAITALL and wxSOCKET_BLOCK everywhere). So if i have a
separate execution path dedicated to send events then it is a good
choice (or is it?)
One last issue bugging my mind: Do i have to use custom events for
synchronizing the threads and communicating between them? What i mean
is, for instance, assume the main thread wants to tell sender thread
to send something because a message has been produced and it needs to
be sent. I believe this task can be handled by using mutexes, main
thread can lock a mutex then set a boolean flag and then unlock, on
the other side sender thread would continuously try to lock and read
the value of the flag to see if it should send something.
Which is the nice and clean way to do this?
More information about the wx-users
mailing list