Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Yeah, I'm responding to my own post. This is because what follows is really a rather off-topic rant on my part, and not really related to the question asked above.

So I got vaguely interested in figuring out what exactly that useless-looking $flags variable was there for. I quickly learned that, unlike $datagram, it's not modified by send or recv, as I had anticipated. Rather, it's says "make me a packet with this set of flags" or "do this special thing when trolling for packets."

It just happens that one of the machines that I tested my UDP code on was a machine running Windows and ActivePerl. So I started poking around, looking at which constant values for the flags were defined. Under Windows, I found exactly four: MSG_OOB, MSG_PEEK, MSG_DONTROUTE, and MSG_MAXIOVLEN. These, of course, were nicely mysterious to me, so I set out to see what I could see about each:

  • MSG_OOB is supposed to be a flag which signals "urgent" or "priority" messages. It's what catches control-C in Telnet connections, for example. When used with recv, it serves as a filter, only recv'ing "priority" packets. It doesn't work with UDP, though.
  • MSG_PEEK allows you to recv the first packet without taking it off of the server's stack of waiting packets. This is of dubious usefulness, but actually works under windows.
  • MSG_DONTROUTE probably does what it implies. I didn't have much way to test this.

And this brings me to my main victim -- MSG_MAXIOVLEN. Not only does it have the most ugly-looking name, it's apparently only defined under Windows. A Google search for it shows up a decent number of hits -- but upon careful perusal, every one of them defines it as a constant with no comment after it. In fact, the Winsock specification does the exact same thing -- defined, with no comment, and never refenced again. In an example of huge-scale cargo-cultism, hundreds of header files, including every Windows-based Perl install out there, have copied an absolutly useless constant which is not implemented or described anywhere. A little further reasearch shows that it might be implemented on the UNICOS/mk cray operating system. And even if it is, it's misnamed, as it's not a flag on a message at all, but an arbitrary constant of the TCP stack!

So there's the sordid tale of a misnamed, unimplmented, useless, but omnipresent constant. Gah!

perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^+*`^ ve^#$&V"+@( NO CARRIER'


In reply to OT: Random useless misnamed Windows constants and cargo-cultism by Chmrr
in thread Simple UDP example anyone? by Anonymous Monk

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 romping around the Monastery: (7)
As of 2024-04-19 07:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found