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)];