Fix checking for socket not being open yet