in reply to Re^6: two-way socket works once only?
in thread two-way socket works once only?

Okay, this definitely works. Thanks for the fix. Now I need to understand a few things.
In server.pl:
why do you have LocalPort => '127.0.0.1',  ###? Shouldn't that be LocalAddress?
why while (defined($incoming = <$client_sock>)) { instead of while ($incoming = <$client_sock>){?
In client.pl:
I don't understand the use of if (0). Is that just to disable that section of code? That is the only thing I can think of...

Again, thanks for the help!

--
Believe nothing, no matter where you read it, or who said it - even if I have said it - unless it agrees with your own reason and your own common sense.
(Buddha)

Replies are listed 'Best First'.
Re^8: two-way socket works once only?
by ikegami (Patriarch) on Nov 29, 2004 at 15:08 UTC

    Yes, LocalPort => '127.0.0.1' is a typo for LocalAddr => '127.0.0.1'. The latter means only accept connections from 127.0.0.1. (Actaully, it means listen for connections whose destination address is 127.0.0.1, which should mean the same thing.) I used that for testing.

    while (defined($incoming = <$client_sock>)) can indeed be simplified to while ($incoming = <$client_sock>). Old habbit. It's not needed here, and it's not needed when doing while (defined($line = <$fh>)), where I picked up the habbit.

    Yes, if (0) is just an easy way to comment out a section. I didn't have a header file.

      Okay, thanks for the explanations. Seems that I basically was hanging things up with my client, and thinking that the problem was with my server. It's all sorted out now, and works like a charm. I cleaned up my code a bit, too... threw some things into subroutines, and quit calling a long list of "my" at the beginning (which even I thought was ugly). I'll provide the "finished" versions if anybody cares to see how it wound up.

      --
      Linux, sci-fi, and Nat Torkington, all at Penguicon 3.0