I have an application that opens a socket on port 4444 to a device (/dev/linkToDevice). The "linkToDevice" is a link to ttyUSB0. The application is a c++ program of which is now a daemon and runs at boot up. The daemon runs regardless of network. So when the linux box is booted, and there is not network, the daemon starts immediately and while there is still no network, I can communicate just fine (telnet localhost 4444). But, when I plug in a network cable, or dhclient determines there is no DHCP and leases me a default ip address, or I just simply give it an ip interface, I can no longer communicate. I can, however, still open the telnet connection, I just get no response when I query for one.
I use 0.0.0.0 as the ip to open the socket on (signifying any ip address). I don't feel like it is a code problem.
The odd part to me is that after I can no longer communicate, if I restart the daemon, everything works great, which is expected. But, when I unplug the network, or unconfigure the interface, or do a sudo /etc/init.d/networking restart, or any sort of bringing the network down and back up again, through that entire process I never lose communication to the device. So the problem ONLY happens when I boot the machine with no network to begin with, and then I all of a sudden get a network. Any thoughts as to why this only happens at boot up?
strace