program works in different ways

if you run the program from /etc/init.d/rcS at the start of the system, ethernet does not work - the program does not respond for a long time by ethernet
if run from the console everything works perfectly

e.g. you have the script run AFTER networking is up. Via a service. You can read my own ramblings about it here.