#!/usr/bin/perl

use IO::Handle;
use IO::Socket;
#use strict;

# suche im phex: "Suchbegriff .Dateityp"

my $socket = IO::Socket::INET->new(PeerAddr => "localhost",
                                PeerPort	=> ###########,
                                Proto		=> "tcp",
								Timeout		=> 3,
                                Type		=> SOCK_STREAM)
    or die "Couldn't connect to host $@\n";
binmode($socket);
$socket->autoflush(1);

# zuerst das "Hi" vom server abholen
my $t = <$socket>;
print "$t\n";

# result reinflippern 
$id = int(rand(100)+1);
my $string = "find $id 0 10000 Any abc paris hilton .jpg";
syswrite($socket, $string , length($string) );	
print "ID $id\n";

# result rausholen 
#$Rstring = "result $id abc";
#syswrite($socket, $Rstring , length($Rstring) );	
#my $tt = <$socket>;

#open(WH,">dump.txt");
#print WH $tt;
#close WH;
# print $tt;


close $socket;
exit;