I have a program, in python, that need to do a reverse DNS for like 1000 IP. To do this I'm using socket.gethostbyaddr, but sometimes, for some reasons, I can't do reverse DNS on my computer so it will take like 3000 seconds to do this because each IP will get me an exception after 3 seconds ( timeout ).
So my problem is that I don't want this, I want to know how I can check that I can't do reverse DNS, so I no longer need to do this and lose 3000 seconds.
I first tried watching the returned exception in the case of a timeout ( because I'm not able to do reverse DNS ), but socket.gethostbyaddr return the same exception as if the IP have an unknown host ( in the case if I'm able to do reverse DNS ).
So how can I do this ?
Thanks.