#!/usr/bin/perl -w use strict; use warnings; use IO::Socket; my $server_port=29000; my $server = IO::Socket::INET->new(LocalPort =>$server_port, Type=>SOCK_STREAM, Reuse=>1, Listen=>10 )# or SOMAXCONN or die "Couldn't be a tcp server on port $server_port : $@\n"; while (my $client = $server->accept()) { # $client is the new connection $client-> autoflush(1); print "$client\n"; my $dataPrint=<$client>; print "$dataPrint"; my $lig="0100031cc00001100100001600000000000000000000010740000045303039362d736573736d67722e73746172656e742d67792d3032313b3437363532393832303b3533363832313038383b35313232333363382d363030320000000000010840000023303039362d736573736d67722e73746172656e742d67792d30323100000001284000001b73746172656e746e6574776f726b732e636f6d000000011b4000001363616d69616e742e636f6d00000001024000000c00000004000001cd40000016333232353140336770702e6f72670000000001a04000000c000000010000019f4000000c00000000000000014000000c766f6964000001164000000c5109e66a000000374000000cd4ccb248000001bb40000028000001c24000000c00000000000001bc40000013333337363133333739323300000001bb4000002c000001c24000000c00000001000001bc4000001732303832303130303134323032323100000001c74000000c00000001000001ca4000002c000001cb4000000c00000000000001cc400000183335343937323035303032323338303100000369c0000180000028af0000036ac0000174000028af00000002c0000010000028af1fc1b44700000003c0000010000028af00000000000004cbc0000012000028af00010a260f0b000000000005c0000025000028af39392d31333932314637333936453845383734383235383738000000000004ccc0000012000028af000150d6f40100000000034fc0000012000028af000150d6f2c0000000000008c0000011000028af32303832300000000000000ac000000d000028af350000000000001ec000001b000028af6d6d73626f75796774656c2e636f6d000000000cc000000d000028af300000000000000dc0000010000028af3038303000000012c0000011000028af323038323000000000000017c000000e000028af40200000000003ec4000002c6d6d73626f75796774656c5f72756c65626173655f464e425f4d6f6e74686c795f34474200000016c0000014000028af0102f8025097b00e00000015c000000d000028af01000000000004dfc0000010000028af00000000"; print "length ago:".length($lig)."\n"; my $lig1=pack("H*",$lig); print "length now:".length($lig1)."\n"; #my $lig2=unpack("H*",$lig1); #print "length now:".length($lig2)."\n"; #select ($client); #$\=chr(4); print $client $lig1."\n"; #print $client $lig2."\n"; #$client->syswrite($lig); #$client->flush(); } close($server); #### #!/usr/bin/perl -w use IO::Socket; use strict; my $remote_host='bt1svmi6'; my$remote_port=29000; my $socket = IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto=> "tcp", Type=> SOCK_STREAM) or die "Couldn't connect to $remote_host:$remote_port : $@\n"; #$wantToSpeak=0; # ... do something with the socket my $lig="Need for Diameter!\n"; print $socket $lig; my $answer = <$socket>; # and terminate the connection when we're done print "I have the response\n"; close($socket); chomp ($answer); print $answer; $answer=unpack("H*",$answer);