in reply to Re: Determinine Protocol In inetd.
in thread Determinine Protocol In inetd.

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

Replies are listed 'Best First'.
Re: Re: Re: Determinine Protocol In inetd.
by Rhandom (Curate) on Apr 30, 2001 at 17:28 UTC
    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)];