camel book example- clien/server 
Author Message
 camel book example- clien/server

Hi Folks;

I was trying to hack the client and server examples from the camel book into
a utility I was working on, and ran into a bit of a snag.  The code in the
book doesn't quite match the code from the oriely site.  Both seem to work,
is there a reason they are different?  Also, would anybody care to give me
a pointer on how to get the server to talk to the client? (text sez the client
will echo what the server sends, but as coded the server doesn't send anything:)

Thx,
M2 - oh, btw- replies to this via mail might bounce (sick sendmail daemon);

Here's the code in the client script that's different:

<<from book>>
for($con = 1; ; $con++) {
     printf("Listening for connection %d....\n",$con);
    ($addr = accept(NS,S)) || die $!;

    if (($child = fork()) == 0) {
        print "accept ok\n";

        ($af,$port,$inetaddr) = unpack($sockaddr,$addr);


        while (<NS>) {
            print "$con: $_";
        }
        close(NS);
        exit;
    }
    close(NS);

Quote:
}

<<From site>>
$con = 0;
print "Listening for connection 1....\n";
for(;;) {
    ($addr = accept(NS,S)) || die $!;

    $con++;
    if (($child[$con] = fork()) == 0) {
        print "accept ok\n";

        ($af,$port,$inetaddr) = unpack($sockaddr,$addr);


        while (<NS>) {
            print "$con: $_";
        }
        close(NS);
        exit;
    }
    close(NS);

    printf("Listening for connection %d\n",$con+1);

Quote:
}



Fri, 18 Jul 1997 16:43:33 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Question on Camel Book example

2. Problem: getpwent() & Camel book example

3. Example from Camel book ( a problem)

4. Prob w/Camel Book example

5. Regex example from Camel book

6. Confused about s/// example in the Camel book

7. Camel Book example Question

8. Question on example in Camel book

9. Error in new Camel book: local filehandles example?

10. perl book socket server example does not work

11. looking for the examples from the Camel book online

12. Camel book examples and -w

 

 
Powered by phpBB® Forum Software