in reply to Re^3: Simple question regarding Bidirectional socket programming
in thread Simple question regarding Bidirectional socket programming

Hi almut, your solution worked just perfect for me, the code is working now after your changes.

I added a condition for break in the while loop for the deadlock.

There is another doubt, I read that $| variable of perl does flusing, so I had used that in the code above, but it didnt work somehow here and when i used IO::Socket and did CLIENT->flush(), it worked.

I didn't understand this. Can you elaborate?

  • Comment on Re^4: Simple question regarding Bidirectional socket programming

Replies are listed 'Best First'.
Re^5: Simple question regarding Bidirectional socket programming
by almut (Canon) on Jun 15, 2010 at 11:26 UTC

    Setting $| applies to the "selected" file handle, which by default is STDOUT. In theory, you could use select (the one argument variant) to have it apply to any other handle (see the example in the docs), but personally, I find the IO::Handle API less cumbersome to use.

Re^5: Simple question regarding Bidirectional socket programming
by ikegami (Patriarch) on Jun 15, 2010 at 18:11 UTC
    You can use
    use IO::Handle; ... CLIENT->autoflush(1); ... print CLIENT "Hello from the server \n\n"; ...
    instead of
    use IO::Handle; ... print CLIENT "Hello from the server \n\n"; CLIENT->flush(); ...

    The first is the same as calling $|=1; with the CLIENT handle selected.

      Thank you guys for putting some light on the topic. You helped me from banging my head on my desk all the day long. Thanks a ton