Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!sdd.hp.com!spool.mu.edu!uunet!mcsun!corton!ircam!fingerhu From: fingerhu@ircam.fr (Michel Fingerhut) Newsgroups: comp.lang.perl Subject: Network byte order problem Message-ID: <1991Feb11.172613.12166@ircam.fr> Date: 11 Feb 91 17:26:13 GMT Sender: fingerhu@ircam.fr (Michel Fingerhut) Organization: IRCAM, Paris (France) Lines: 17 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.