LinBPQ has a facility to make a tcp connection from the node to an
application running on the same machine. This was originally intended
to connect to a shell to enable basic configuration editing, but has
been
generalised to allow connects to other tcp ports, thus allowing you to
write your own applications to be used with LinBPQ.
This document describes one way to do this, and includes a sample
program. There are other ways, but this works, and is easy to set up.
The idea comes from this website.
Note that although this was added for LinBPQ, it
ia also available on the Windows version.
Allocate a TCP port for each application. You can use any that aren't used by other programs. Add a CMDPORT line to the Telnet Server config listing the port(s)
CMDPORT 23
63000 ;This allows connects
to the telnet server and your app
Add APPLICATION Line for each. These assume your Telnet Port
is port 2.
APPLICATION 1,LINUX,C 2 HOST 0 S
APPLICATION 2,DEMO,C 2 HOST 1 S
The number before the S indexes the port numbers in CMDPORT. The S
is optional - it means that the user will be returned to the node when
he/she closes the application instead of being disconnected.
Normally the connecting user's callsign will be sent to the application. You can add the parameter NOCALL to overrive this.
If your users need to remain connected to the application for long periods without sending any input you can add K to enable Keepalive messages to be sent to the node.
If S is specified it must be after any optional parameters, eg C 2 HOST 1 NOCALL K S.
You can add the usual Callsign, Alias and Quality params after the application definition if you want your
application to be accessible from other nodes on the network.
Add lines to /etc/services and /etc/inetd.conf for each of your applications
/etc/services
# Local services
bpqdemo
63000/tcp # BPQ Demo App
/etc/inetd.conf
bpqdemo stream tcp nowait pi /home/pi/linbpq/testapp.pl
Change pi to whatever user you run LinBPQ as.
Restart inetd - sudo killall -1 inetd
This simply accepts input and echos it back.The Node sends the call
of the user when the ocnnection is made. This is written in perl, as it
was the first example I found. Any language could be used. Input is on
STDIN, output on STDOUT.
#!/usr/bin/perl -w -T
# sinet.pl A simple inetd socket server.
use strict;
my $old_fh = select(STDOUT);
$| = 1;
select($old_fh);
my $line =;
print "Hello " . $line . "Welcome to my LinBPQ Demo App. type exit to close\n";
while( my $line =)
{
$line =~ s/\r?\n$//;
if ($line =~ /exit/)
{
die "shutting down\n";
}
# do your processing here!
print " $line\n";
}
This can be downloaded from here. Save in your linbpq directory and set as executable.