minor fix : use the return value from write_socket() correctly