improved socket handlings, now supporting reconnects