Moved socket binding before closing std file desc. Improved logging