This is probably the easiest approach. Another is to try to get the TCP option TCP_MAXSEG and if it fails, it is a UDP socket.
You can, however, get the info you want if you are using Linux. I don't know about other OSs as I don't have any other development platforms here. If you do a getsockopt SOCK, SOL_SOCKET, SO_TYPE;
it will (should?) return SOCK_STREAM for stream (TCP) sockets and SOCK_DGRAM for datagram (UDP) sockets. This looks like it works from C, but on my perl5.005003 it seems to have a problem. Maybe it's my system...HTH, traveler | [reply] [d/l] |
After investigating it, you are correct. That would be the best way to get it. However, it is disabled in most of the perl versions I have looked at. Thanks for the work. I'll have to continue recording information the way that I was.
perl -we 'use Socket; Socket::getsockopt()'
Your vendor has not defined Socket macro getsockopt, used at -e line 1
my @a=qw(random brilliant braindead); print $a[rand(@a)]; | [reply] [d/l] |
I mentioned this as a possibility. If I have to I will. But
I would rather that the code could determine it on its own.
Even without passing parameters I could write a dummy script:
#!/usr/bin/perl
exec "MyRealProg.pl --proto=udp"
Course, this would be a double exec.
Is there any way to do it (suppose I wasn't in inetd and I
was passed some fileno's of sockets to connect to -- is there
a way to determine?)
my @a=qw(random brilliant braindead); print $a[rand(@a)]; | [reply] [d/l] |
| [reply] |
But I would rather that the code could determine it on its own.
identd has the protocol in hand, yet you prefer to drop this knowledge on the floor and then rederive it downstream. Curiousity about how you might be able to derive the discarded prototype info is one thing, but from a pragmatic point of view, this is wasteful a approach.
| [reply] |