#!/usr/local/apps/perl/bin/perl ############################################################################ # # # WHO: John L. Moreland # # # # WHAT: client # # # # WHY: Demonstrates how to use a client socket. # # # # WHERE: Opus Software # # # # WHEN: Wed Oct 7 18:36:56 PDT 1998 # # # # HOW: Perl # # # ############################################################################ ############################################################################ ################################## INIT ################################## ############################################################################ use Socket; $host = $ARGV[0] || "localhost"; $port = $ARGV[1] || 6660; ############################################################################ ################################## MAIN ################################## ############################################################################ # Open a client socket socket( S, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2] ) || die $!; connect( S, pack_sockaddr_in( $port, inet_aton( $host ) ) ) || die $!; select( S ); $| = 1; select( STDOUT ); # Set socket to be command buffered while ( 1 ) { $line = ; # Read a line from STDIN print S $line; # Write the line to the socket }