Added non-blocking IO to the socket opening function