bi-directional inetd communication between perl scripts

bi-directional inetd communication between perl scripts

Post by hen » Tue, 22 Jan 2002 18:30:14



Hello,

    I'm trying to make an inetd perl server to communicate with a perl
client. Communication from client to server is working but not from
server to client. As I understand inetd handles the socket, bind,
listen and accept stuff and basically you can communicate between
server and client using STDIN and STDOUT.

Is there anybody who can help me and get me going again?

Thanks Henk

This is what I've got sofar.

==/etc/services======================================================
psad            1200/tcp              # Test perl inetd daemon
==/etc/inetd.conf ====================================================
psad  stream  tcp    nowait  root    /tmp/server.prl

==server.prl========================================================
#!/usr/bin/perl

open (OUTFILE, ">/tmp/effe1");  # Open output file
select(OUTFILE); $|++;          # Unbuffered output OUTFILE
select(STDOUT); $|++;           # Unbuffered output STDOUT

while (<STDIN>) {
    print OUTFILE $_;           # Write client lines to OUTFILE

Quote:}

print "Output for standard out\n";      # Send lind to client
close (OUTFILE);                        # Close output file

==client.prl==========================================================
#!/usr/bin/perl

use IO::Socket;

# Setup connection to server , for now on same host
$sock = IO::Socket::INET->new(  PeerAddr    => 'localhost',
                                PeerPort    => 1200,
                                Proto       => 'tcp',
                             );
unless ($sock) {die "Socket could not be created, Reason: $!"}

foreach (1..100) {
    print $sock "Line $_\n";    # Send lines to server

Quote:}

# Hope to receive output from server and store in file
open (OUTFILE, ">/tmp/effe2") || die "can't open outfile $!";
$a = <STDIN>;
print OUTFILE $a;

close (OUTFILE);        # Close output file
close ($sock);          # Close connection

 
 
 

1. Bi-directional inetd communication

Hi,

  I'm trying to write an inetd perl server which should have
bi-directional communication with a perl client script. The
communication between the client and server is working but between the
server and the client isn't. Does anyone can help me further here. Any
help would be appriciated very much.

Thanks Henk

====================/etc/services
psad            1200/tcp                   # Process sar AIX daemon

====================/etc/inetd.conf
psad  stream  tcp    nowait  root    /tmp/server.prl

====================/tmp/server.prl
#!/usr/bin/perl

binmode(STDIN);
binmode(STDOUT);
open (OUTFILE, ">/tmp/effe1");  # Open output file
select(OUTFILE); $|++;          # Unbuffered output OUTFILE
select(STDOUT); $|++;           # Unbuffered output STDOUT

while (<STDIN>) {
    print OUTFILE $_;           # Write client lines to OUTFILE

print "Output for standard out\n";      # Send lind to client
close (OUTFILE);                        # Close output file

====================/tmp/client.prl
#!/usr/bin/perl

use IO::Socket;

$\="\r\n";                      # Output delimiter
# Setup connection to server , for now on same host

$sock = IO::Socket::INET->new(  PeerAddr    => 'localhost',
                                PeerPort    => 1200,
                                Proto       => 'tcp',
                             );
unless ($sock) {die "Socket could not be created, Reason: $!"}
$sock->autoflush(1);                    # prevent buffering $sock
select((select($sock),$|=1)[0]);

foreach (1..100) {
    print $sock "Line $_";  # Send lines to server

# Hope to receive output from server and store in file

open (OUTFILE, ">/tmp/effe2") || die "can't open outfile $!";
$a = <$sock>;
print OUTFILE $a;

close (OUTFILE);        # Close output file
close ($sock);          # Close connection

2. ssh authentication

3. Bi-directional inted communications

4. IPv6 flowlabel

5. bi-directional parallel communications

6. Red Hat 5 Partition LILO/DOS/NTFS problem newbie needshelp.urgent

7. bi-directional parallel ports/brother HL-630

8. find command way to slow!

9. Bi-directional parallel port device

10. Bi-Directional Modem Installation FAQ?

11. Uni versus bi-directional traffic

12. Bi-directional modem line - not FAQ (?)

13. Bi-directional modem setup.....