# check_socket(host, port, handle, [&error])
sub check_socket
{
local($addr, $h); $h = $_[2];
if (!socket($h, PF_INET, SOCK_STREAM, getprotobyname("tcp"))) {
	if ($_[3]) { ${$_[3]} = &text(sckerr_no, $!); return false; }
	else { &error("&text(sckerr_no, $!)"); }
	}
if (!($addr = inet_aton($_[0]))) {
	if ($_[3]) { ${$_[3]} = &text(sckerr_noip, $_[0]); return false; }
	else { &error("&text(sckerr_noip, $_[0])"); }
	}
if (!connect($h, sockaddr_in($_[1], $addr))) {
	if ($_[3]) { ${$_[3]} = &text(sckerr_noconn, $_[0],$_[1],$!); return false; }
	else { &error("&text(sckerr_noconn, $_[0],$_[1],$!)"); }
	}
        # select($h); $| =1; select(STDOUT);
        shutdown($h,2);
}
