Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!rbj From: rbj@uunet.UU.NET (Root Boy Jim) Newsgroups: comp.lang.perl Subject: Re: Network byte order problem Message-ID: <122378@uunet.UU.NET> Date: 11 Feb 91 22:47:21 GMT References: <1991Feb11.172613.12166@ircam.fr> Organization: UUNET Communications Services, Falls Church, VA Lines: 23 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 I got a head full of ideas They're driving me insane