in reply to Re: Timeout Socket recv on UDP... on windows
in thread Timeout Socket recv on UDP... on windows

IMHO... it would be preferable to at least mention the symbolic name of the constant, FIONBIO in this case, in preference to just giving the value as 0x8004667e. Otherwise, we risk giving even more Perl newbies the idea that it's cool to write code with mysterious, arbitrary large hex constants in it.

Perl code is scary* enough to users, even without making it look like we are trying to sneak a concealed Dark Ritual Invocation of the Name of the Beast into our code.

* Alas, "scary" is exact word my boss used yesterday when he looked at a one-liner I dashed off for him. That's bad, very bad....

  • Comment on Re^2: Timeout Socket recv on UDP... on windows

Replies are listed 'Best First'.
Re^3: Timeout Socket recv on UDP... on windows
by BrowserUk (Patriarch) on Jan 26, 2008 at 11:54 UTC

    I'm not at all sure that an arbitrary collection of 7 uppercase letters is any better.

    It would only turn up 9 of the 33 posts the search term I gave turns up. And I'm not sure that 9 are relevant. The 33 definitely are. It's very unlikely that number would turn up in any other context.

    And I'm not sure that it would do anything to help them. As that symbolic constant isn't available to them from Perl.

    And I'm not sure it would help them work out the value they need either. Even if they have the relevant C header files, FIONBIO is defined there as:

    #define FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i +/o */

    And the relevant parts of that are defined as:

    #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|( +(x)<<8)|(y)) #define IOCPARM_MASK 0x7f #define IOC_IN 0x80000000 /* copy in parameters */

    Now, I think I'm pretty offay with C and bit-twiddling, but I'm not sure that I could work out what the required number is from that lot.

    And I'm not at all sure that I could recreate that math in Perl.

    That's a lot of "not sures". I am sure that if I use the hex constant, it finds the posts. And works.


    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.
      True, there is little about the string "FIONBIO" in Perl, and your rant about the perverse tastes of the writers of the C header code is on the mark.

      However, including the conventional name of the symbol, even as a comment, allows you to seach for the documentation of the corresponding driver code. For instance, a Google search for "fionbio ioctl site:microsoft.com" finds an MSDN article on "Winsock IOCTLs". In Linux-land, "fionbio driver source" turns up Chapter 6 of the Linux Device Driver book.

        For instance, a Google search for "fionbio ioctl site:microsoft.com" finds an MSDN article on "Winsock IOCTLs".

        Okay, but does that page tell your average Perl programmer anything useful?

        But google for 0x8004667e, and it turns up 600 hits, the first 50 of which are almost all more relevant and useful.


        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.