#!/usr/bin/perl #!/usr/local/bin/perl use IO::Socket; # IO::Socket モジュールを使う。 # ホスト名とポート番号を設定 $host = 'localhost'; $port = 2341; $command = shift || "forward"; print "$host:$port に接続します。¥n"; $socket = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp', ); if ( ! $socket ){ die "接続できませんでした。 $!¥n"; } # 文字列を送信 print "送信メッセージ: $command¥n"; print $socket "$command"; $socket->flush(); # 文字列を受信 #$buf = <$socket>; #print "受信メッセージ: $buf"; $socket->close();