IMG tags and other DOM elements I came up with the following solution.
The code depends on your connection speed and might not be very accurate. Please adjust the timeout value to achieve better results. This tool has been tested on IE and Firefox. Firefox does not allow connections to very low ports such as 7, 21, etc. I haven't tested it on other browsers although it should work more or less the same way.