Fix socket2

Another fix for issue 245, maybe more complete, until we figure out the mutex problem