Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^9: Does IO::Select work? Anywhere?

by zentara (Archbishop)
on Oct 23, 2012 at 14:23 UTC ( #1000482=note: print w/ replies, xml ) Need Help??


in reply to Re^8: Does IO::Select work? Anywhere?
in thread Does IO::Select work? Anywhere?

Ok, I will put my mind to it. I followed your instructions and yes, it does as you say block. My first thought is isn't it clever the way the MIComplex designed our socket connections, so that they can jam any socket based system they want? ;-)

Even though you denigrated the earlier good professor's code of sysreading 1 byte at a time, in Re^4: Does IO::Select work? Anywhere?

while ($c ne "\n" && ! $endoffile) { if (sysread($filehandle, $c, 1) > 0) { $retstr = $retstr . $c; } else { $endoffile=1; } }
maybe therin lies your answer?

The intuitive side of my brain points you to IPC3 buffer limit problem, where you can use syscntl statements. Merlyn says it's effective, except for one case. :-) So I figure, what are the odds? The odds that the last buffer is exactly 4k? 1 in 4k ? Pretty good odds. :-) But then again, I don't fly spaceships either. :)

P.S. I tried your hanging script on the server in Glib based forking server with root messaging and the server handled it just fine. It continued reading messages from clients, and accepted new clients. Sometimes, you just have to learn to use modules instead of reinventing the conveyor belt.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh


Comment on Re^9: Does IO::Select work? Anywhere?
Download Code
Re^10: Does IO::Select work? Anywhere?
by BrowserUk (Pope) on Oct 23, 2012 at 20:50 UTC
    Even though you denigrated the earlier good professor's code of sysreading 1 byte at a time, in Re^4: Does IO::Select work? Anywhere? maybe therin lies your answer?

    No, It doesn't. Plug that into your server and replace the call to perl's readline with a call to that -- and exactly the same thing will happen. Which is why I denigrated it.

    If you're happy with not understanding why glib works, that's your call.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

      if you're happy with not understanding why glib works, that's your call.

      Oh I don't understand how most modules do what they actually do, thats why I use them. For what it's worth, the code you are probably looking for is in gio/gsocket.c

      For me to guess at how to do it with plain select, I think you need to figure out how to access the socket's errno. See getting errno. From Perl you probably need to use sysctl.ph

      P.S. Glib is not the only lib out there, many prefer AnyEvent. Have you looked at how AnyEvent works against your socket blocker program?


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000482]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-08-22 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (156 votes), past polls