Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!haven!decuac!shlump.dec.com!michaud From: michaud@decvax.dec.com (Jeff Michaud) Newsgroups: comp.unix.ultrix Subject: Re: Problem with getservbyname (Ultrix-32 V3.0 (Rev 64) ) Message-ID: <3674@shlump.dec.com> Date: 21 Jul 89 21:57:47 GMT References: <3459@ncsuvx.ncsu.edu> Sender: news@shlump.dec.com Distribution: usa Lines: 20 In article <3459@ncsuvx.ncsu.edu>, map@cscosl.ncsu.edu (Mark Parris) writes: > When I attempt to get the port address of a service using getservbyname > the port number that is returned is the actual port number times 256 (or > shifted 8?) mod 65535. I can use this number in the getservbyport and it > returns the same port. The true port value returns a null. From the man page: s_port The port number at which the service resides. Port numbers are returned in network byte order. which is the same byte order which it should be shoved into sockaddr_in. In order to get it in the right byte order to print out in human readable form you need to use the ntohs() routine. -- /--------------------------------------------------------------\ |Jeff Michaud michaud@decwrl.dec.com michaud@decvax.dec.com| |DECnet-ULTRIX #include | \--------------------------------------------------------------/