>>If you are keeping it in memory, then your system must have run out of memory. Memory leak or not. Could you please explain this?
What LamaBot meant was if you're keeping data in process memory (say some local/global/member variables) then as new messages keep coming space/memory occupied by all these variable will increse. Sooner or later this will go above the allowed (by OS per process) memory limit and proc will be killed.
Is there any max limit on the threads that can be created from the application?
Yes. But it's much higher than 2, so that won't be a problem for you. FYI see "man getrlimit"
Client has been killed after few hours of inactivity, then the gush of messages from server has occurred.
If indeed the client was killed after a few hours of inactivity. You can use following to get more info.
1. Which signal killed the process? Once you know which signal see "man signals".
2. Call stack at the time of killing (pstack core)
3. While your client is 'idle/inactive' (before it is killed, running but doing nothing) you can periodically check the pstack to see why/where-in-code is the thread waiting. (pstack <pid>)
Last but not the least, I still say the same thing, it seems like memory corruption.
Run your code under purify.