Here is a fun one that I would love to see an answer to. I
have a server class that can simultaneously bind to a port
under UDP and TCP. When I bind to port I keep track of which
fileno is open to each protocol. Because of this,
when I receive a connection, I can use my internal table of
fileno's to look up which protocol was bound on it.
Now the trick. I also have my server able to run from inetd
(or xinetd). The problem is here that when a connection comes
in, I don't know if I'm looking UDP or TCP (remember, I can bind
the same port and same host under different protocols at
the same time under the regular server -- inetd can also, but
it doesn't tell me which one I received). So, the question
is, is there a method that will give you which protocol is
being used. I have looked at
Socket
and I have looked at
IO::Socket
and I have looked at
IO::Socket::INET
but with little success. I have even guessed some method names
out of the air. Is there anybody with insight into the socket
internals who has any idea? Is this even possible?
Any ideas? There is the option of using separate programs
for UDP and for TCP. I don't want to do this though (I don't
need to under my regular server -- I'd like to maintain
the same code base).
The winner will get their name in lights (or at
least a mention in the module credits) (but we don't do things
for fame around here do we {grin}).
my @a=qw(random brilliant braindead); print $a[rand(@a)];
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.