M
Martijn Lievaart
Hi,
Sorry, no code. Normally I just code something up and work it out from
there. I want to get a grasp on the basic concepts before starting to code
for this one.
I've written a small server that listens for UDP packets or TCP
connections, computes an answer and returns the result. The trouble is
that computing the answer may be almost instantanious, or may take several
seconds. I want to make the server concurrent by using ithreads, creating
n threads and distributing the requests over the threads using
Threads::Queue. The thread itself should send back the result to the
client.
Now I understand the basics of :shared. I just cannot wrap this around to
sockets.
For TCP: Can I just enqueue a socket and use it in the thread that
dequeues it? Or should the socket be marked shared? Or will this not work
at all? Or depending on the OS (I'm using Linux).
What would be an appropriate model for UDP? I probably can just create a
UDP socket per thread and use that to send the answer, am I on the right
track?
Thanks in advance for any insight anyone can give on this.
M4
Sorry, no code. Normally I just code something up and work it out from
there. I want to get a grasp on the basic concepts before starting to code
for this one.
I've written a small server that listens for UDP packets or TCP
connections, computes an answer and returns the result. The trouble is
that computing the answer may be almost instantanious, or may take several
seconds. I want to make the server concurrent by using ithreads, creating
n threads and distributing the requests over the threads using
Threads::Queue. The thread itself should send back the result to the
client.
Now I understand the basics of :shared. I just cannot wrap this around to
sockets.
For TCP: Can I just enqueue a socket and use it in the thread that
dequeues it? Or should the socket be marked shared? Or will this not work
at all? Or depending on the OS (I'm using Linux).
What would be an appropriate model for UDP? I probably can just create a
UDP socket per thread and use that to send the answer, am I on the right
track?
Thanks in advance for any insight anyone can give on this.
M4