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

https://wiki.debian.org/LSBInitScripts

e.g. you have the script run AFTER networking is up. Via a service. You can read my own ramblings about it here. http://www.embeddedhobbyist.com/debian-tips/beaglebone-black/beaglebone-black-init-scripts-default-gatewayand-ntpdate/