fingerhu@ircam.fr (Michel Fingerhut) (02/12/91)
Setup: perl 3.0 patch level 44 DECsystem 5810, Ultrix 4.0 I have a problem with the getservbyport call. It has to do with the way the port number has to be fit in. The call getservbyport(513, "tcp") (513 is port number for login) fails with errno = 0. If, however, I pass it 258, which is htons(513), it works. How do I go about simulating a htons with pack/unpack tho' is beyond me. I suppose it's trivial but my mind is frozen. Any help? Remark: getservbyname does NOT return the port value in network order, so plugging into my call the returned value does not work, which is not quite the way it should be.
rbj@uunet.UU.NET (Root Boy Jim) (02/12/91)
In article <1991Feb11.172613.12166@ircam.fr> fingerhu@ircam.fr (Michel Fingerhut) writes: > >(513 is port number for login) fails with errno = 0. >If, however, I pass it 258, which is htons(513), it works. > >How do I go about simulating a htons with pack/unpack tho' is beyond me. >I suppose it's trivial but my mind is frozen. Any help? To generate perverted, brain dead, big endian format from normal, sane, little endian, do the following: /home/rbj/ndc [rbj@uunet 71] perl -de 0 DB<2> p unpack('n',pack('s',513)) 258 DB<4> p unpack('s',pack('n',513)) 258 The above will be a noop for big endian machines. -- Root Boy Jim Cottrell <rbj@uunet.uu.net> I got a head full of ideas They're driving me insane