my $written = syswrite($sock, $buf, 1024); if (not defined $written) { close_sock($sock); }