cygwin also does not give error on disconnect. r == 0 check needs to be
present on any OS