#!/usr/bin/perl use TL1ng::Telnet; use Data::Dumper; $| = 1; # Autoflush STDOUT my $tl1 = new TL1ng::Telnet( timeout => 10, hostname => '127.0.0.1', port => 12345, connect => 0, # Don't auto-connect. ); $tl1->connect(); print "TL1 Connection opened\n" if $tl1->connected(); while($tl1->connected()) { while(my $msg = $tl1->get_next()){ print Dumper $msg; } } #### #!/usr/bin/perl use IO::Socket; #$| = 1; my $sock = new IO::Socket::INET ( LocalHost => '127.0.0.1', LocalPort => '12345', Proto => 'tcp', Listen => 1, Reuse => 1, ) || die "Could not create socket: $!\n"; print "Socket created, listening for client connection...\n"; my $client = $sock->accept(); $client->autoflush(1); print "Client connected, sending data...\n\n"; print "\n"; while() { chomp; /^$/ ? print $client "$_\n" : print $client "$_\015\012"; while () { chomp; if (/^$/) { print $client "$_\n"; last } print $client "$_\015\012"; } # select can simulate sleeping for fractions of a second. my $yfact = int(rand() * 1000)/1000; my $xfact = int(rand() * 1000)/1000; my $sleep = int($xfact * $yfact * 100 - 10)/100; select(undef, undef, undef, abs $sleep); } print "All data sent. Quitting.\n\n"; __DATA__ ALBNYN51 2007-07-27 17:33:40 A 4164.4164 REPT EVT T1 "FAC-1-2:T-ESL,TC,,,FEND,,65,65,15-MIN:\"Performance Monitor Threshold Crossing Alert\"," ; LAWMAN01 2007-07-27 17:33:40 A 618.616 REPT ALM T1 "FAC-14-9:CL,AIS,NSA,,,,:\"Alarm Indication Signal\",DS1-14" ; BOSMAN51 2007-07-27 17:33:40 A 8964.8963 REPT ALM VT1 "VT1-6-1-29-1-1:CL,RFI-V,NSA,,,,:\"Remote Failure Indication - VT\",OC48" ; LAWMAN01 2007-07-27 17:33:40 ** 619.619 REPT ALM T1 "FAC-14-9:MJ,LOF,SA,,,,:\"Loss Of Frame\",DS1-14" ; BOSMAN51 2007-07-27 17:33:40 A 8965.8962 REPT ALM VT1 "VT1-6-1-29-3-2:CL,RFI-V,NSA,,,,:\"Remote Failure Indication - VT\",OC48" ; BANMEN01 2007-07-27 17:33:40 A 7623.7623 REPT EVT T1 "FAC-4-2:T-SEFS,TC,,,FEND,,25,25,15-MIN:\"Performance Monitor Threshold Crossing Alert\"," ; SYRNYN51 2007-07-27 17:33:42 A 6443.6443 REPT EVT T1 "FAC-1-8:T-ESL,TC,,,FEND,,65,65,15-MIN:\"Performance Monitor Threshold Crossing Alert\"," ; LAWMAN01 2007-07-27 17:33:43 A 620.619 REPT ALM T1 "FAC-14-9:CL,LOF,SA,,,,:\"Loss Of Frame\",DS1-14" ; LAWMAN01 2007-07-27 17:33:43 A 621.621 REPT EVT T1 "FAC-14-9:T-UASP,TC,,,FEND,,10,10,15-MIN:\"Performance Monitor Threshold Crossing Alert\"," ; LAWMAN01 2007-07-27 17:34:30 A 632.632 REPT EVT T1 "FAC-4-2:T-ESL,TC,,,FEND,,65,65,15-MIN:\"Performance Monitor Threshold Crossing Alert\"," ; LAWMAN01 2007-07-27 17:34:30 A 633.627 REPT ALM T1 "FAC-14-9:CL,RAI,NSA,,,,:\"Remote Alarm Indication\",DS1-14" ; bosman62 2007-07-27 18:00:54 A 6962.6960 REPT ALM VT1 "VT1-6-1-30-7-2:CL,RFI-V,NSA,,,,:\"Remote Failure Indication - VT\",OC48" ;