[0.2.2] bind event handlers before allowing socket writes

Signed-off-by: Eli Skeggs <eskeggs@globesherpa.com>