Thursday, March 6, 2008

Simple TEC port listener - great for testing

Have you have wanted to test an event, but did not want to send it to TEC or wanted to send it somewhere else? Or you just didn't feel like loading that BAROC file right now?

This PERL script is a TCP Port listener. Very easy to use. I setup programs like ITM 6.1 and Mercury to send events to the IP address where I run this listener. That way I don't have to maintain a TEC and it is zero overhead.

Here is the code - enjoy.

#!c:/perl/bin/perl
use IO::Socket;
my $file = ">>c:/temp/listen.out";
#Create socket
my $socket = IO::Socket::INET->new(Proto => "tcp",
LocalPort => 5529,
Listen => SOMAXCONN,
Reuse => 1);
#Listen for Connections
while( my $client = $socket->accept())
{
my $buffer = <$client>;
print STDERR qq|Received: "$buffer"|;
my $date = localtime time;
}

No comments: