excellent but do i have to re-write the server for this to work?
On Mon, Sep 23, 2002 at 12:30:57 +0200, NYIMI Jose (BMB) wrote:
> use a special forking form of open :
>
> The open function, when passed as its second argument either "-|" or
> "|-" will implicitly pipe and fork. This makes the piping code above
> slightly easier. The child talks to the parent over STDIN or STDOUT,
> depending on whether "-|" or "|-" was used.
>
>
> Example ( Not tested ...) :
>
> #!/usr/bin/perl -w
> # biclient - bidirectional forking client
>
> use strict;
> use IO::Socket;
> my ($host, $port, $kidpid, $sock, $line, $from_parent, $auth, $ip);
>
> unless (@ARGV == 2) { die "usage: $0 host port" }
> ($host, $port) = @ARGV;
>
> # create a tcp connection to the specified host and port
> my $sock = IO::Socket::INET->new( Proto => "tcp",
> PeerAddr => $host,
> PeerPort => $port)
> or die "can't connect to port $port on $host: $!";
>
>
> $sock->autoflush(1); # so output gets there right away
>
> print STDERR "[Connected to $host:$port]\n";
>
> # split the program into two processes, identical twins
> $kidpid = open(CHILD, "|-") || die "can't open/fork: $!";
>
> if ($kidpid) {
> # run parent code, reading from socket
> # and writing to child
> while (defined ($work = <$sock>)) {
> print CHILD $work;
> }
> kill("TERM" => $kidpid); # send SIGTERM to child
> }
> else {
> # otherwise run child code here, reading from parent
> # and writing to your socket
> if ($from_parent = <STDIN>){
> $auth=&get_auth;
> $ip=&get_ip;
> print $sock "ip=$ip";
> print $sock "auth=$auth";
> };
> exit;
> }
> exit;
>
> sub get_auth{
> #write your auth code here
> }
>
> sub get_ip{
> #write your code here that return the your ip
> }
>
> __END__
>
>
> > -----Original Message-----
> > From: Mat Harris [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, September 23, 2002 10:19 AM
> > To: [EMAIL PROTECTED]
> > Subject: client-server with socket
> >
> >
> > i have got the multithreaded server example from perldoc but
> > i need a client that will connect, and upon recieving a
> > certain work from the server, send some authentication
> > details and the current ip address of the client.
> >
> > this is for a dynamic dns solution. I need to have the client
> > send and recieve info to and from the server, but there don't
> > seem to be any examples of this 2-way conversation.
> >
> > --
> > Mat Harris OpenGPG Public Key ID: C37D57D9
> > [EMAIL PROTECTED] matthewh.genestate.com
> >
>
>
> **** DISCLAIMER ****
>
> "This e-mail and any attachment thereto may contain information which is
>confidential and/or protected by intellectual property rights and are intended for
>the sole use of the recipient(s) named above.
> Any use of the information contained herein (including, but not limited to, total or
>partial reproduction, communication or distribution in any form) by other persons
>than the designated recipient(s) is prohibited.
> If you have received this e-mail in error, please notify the sender either by
>telephone or by e-mail and delete the material from any computer".
>
> Thank you for your cooperation.
>
> For further information about Proximus mobile phone services please see our website
>at http://www.proximus.be or refer to any Proximus agent.-- Mat Harris OpenGPG Public Key ID: C37D57D9 [EMAIL PROTECTED] matthewh.genestate.com
msg30936/pgp00000.pgp
Description: PGP signature
