Fixed socket bug found by capi_x