Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
But can you see a reason why this shouldn't also work under Linux?

Are ioctls platform portable? I have no idea. There is probably a POSIX-architected method for switching the blocking/non-blocking state of a socket. From a quick scan, maybe sockopt() in IO::Socket?

To be honest, I think I would just use if( $^O == 'mswin32' ) {...} else {...} and have done with it.

<Aside:>

When you write cross-platform code, there will always be conditional code, but the lower the level at which you try to apply the conditional: a) the more frequent it will be required; b) the harder it will be to maintain.

I've seen code (some of it in the perl core, others in perl modules), where every 3 or 4 lines of actual operational code is wrapped in some platform conditional. The result is that sometimes half a source files 'weight' is the compile-time conditions themselves. This is a nonsense.

Far better to have one file per platform (or flavour of), and a small file that conditionally incorporates the appropriate one at compile-time. Each platform dependant file is free of conditionals and can fulfill its function 'natively' without regard to the constraints of others.

People do (and will) claim that this violated the once and once only principle, and it does. But the benefits outweight the drawback--especially when it comes to maintainance, which is the "people's beef against it--because the clarity is provides, and the freedom from artificial constraint it avails, far outweights the cost of c&p code re-use.

(Sigh!}(Sorry merlyn). This is one one those truths that freshly minted CS-majors will not understand, and will argue against vociferously, until they are no longer newly minted, and are encountering their (5th, 15th, 50th) CS-dogma-optimal, every-3rd-line-is-an-OS-conditional piece of code. And then they'll recognise the wisdom behind these words.

But that takes 5 to 15 years of post-college experience, and those prepared to entertain debates on those (extended) timescales are few and far between these days. In the advertising trade, they attempt to measure and maximise our google;//advertising "attension span" (It's annoying, but illuminating to follow and read a few of those links),.

Depending upon which links you choose to read, the consesus (wet finger in the air), is that it has dropped from around 12 minutes in the 1960s, to around 5-75 seconds today depending upon context. Computers are very good (and very fast) and following deeply nested sets of rules and conditions. Human beings are not. The programmer that can maintain a sense of which of 2 or 3 conditionals is concurrent at any given time, is a very rare animal. Following 4 or 5 compile-time conditions in a single file in neigh impossible. Six is!

<Rant off>


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.

In reply to Re^3: Timeouts: Any alternative to alarm in Win32? by BrowserUk
in thread Timeouts: Any alternative to alarm in Win32? by jbbarnes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found