Using Poco sockets. Finally found the 6 month old bug...had nothing to do with threads. Using Poco::Net::DNS and dns names instead of IPs in db