inetd bi-communication
[email protected] ("henk b") Mon, 21 Jan 2002 10:06:52 +0100
| Newsgroups | perl.libnet |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I'm aware that this is very likely not the correct mail listing but
since it's network related I hope someone in this group might be willing to
help me with my problem.
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. But it's not working and I'm lacking some knowledge. I've
read chapter 6 of Programming Perl and chapter 12 of Advanced Programming
but they just don't seem to have the answer I'm looking for.
Is there anybody who can help me and get me going again?
Thanks Henk
==/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
}
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
}
# 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
_________________________________________________________________
Join the worlds largest e-mail service with MSN Hotmail.
http://www.hotmail.com