Jul 30, 2001, 3:44 PM
Post #1 of 2
I'm trying to make a perl script that asks for remote host, remote port and connects. This is what I have so far, but I'm not sure if there is any way I can view things from the socket, while being able to type into the socket:
print "Remote Host: ";
$host = <STDIN>;
$host =~ s/\n//gi;
print "Remote Port: ";
$port = <STDIN>;
$port =~ s/\n//gi;
print "\nCreating Socket...\t";
socket(SH, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die $!;
print "OK.\nCreating Destination...\t";
$dest = sockaddr_in($port, inet_aton('$host'));
print "OK.\nConnecting to server...\t";
connect(SH, $dest) || die $!;
print "Selecting Socket Handle, Flushing, Selecting STDOUT...\t";
select(SH); $| = 1; select(STDOUT);
# This is where I want the sending/receiving to being..
# But I cannot figure out a way to do this. I can't even figure out how to receive input from the remote host.
Can anyone help me...?
print "\n\nClosing Connection.\n\n";