You can use the
handle function to determine the type of an object. However, this function only knows engine objects (surprise, surprise), but if I see this right, this is what you wanted.
Btw, do I see this right? You do synchronous networking on the mainthread? If so: Thats fucking evil! DON'T! DNS has a 30 second timeout while TCP has a 75(!) second timeout, not to mention the latency which you also need to keep in mind! Thats way to long for an realtime application!