############ # open_TCP # ############ # # Given open_TCP($file_handle, $dest, $port) # # Input: $file_handle is the name of the filehand to use # Input: $dest is the destination ip or domain # Input: $port is the port number # # Output: return 1 if successfull, undef when unsuccessful. use Socket; sub open_TCP { # get paramaters my ($FS, $dest, $port) = @_; my $proto = getprotobyname('tcp'); socket($FS, PF_INET, SOCK_STREAM, $proto) || die $!; my $sin = sockaddr_in($port,inet_aton($dest)); connect($FS,$sin) || return undef; my $old_fh = select($FS); $| = 1; select($old_fh); 1; } 1;