Fix bsd socket issues on connection