From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,10bf95f665757cee,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-03-10 15:20:43 PST Path: gmd.de!newsserver.jvnc.net!yale.edu!yale!gumby!wupost!howland.reston.ans.net!vixen.cso.uiuc.edu!hoohoo.ncsa.uiuc.edu!robm From: robm@ncsa.uiuc.edu (Rob McCool) Newsgroups: comp.unix.osf.osf1 Subject: sin_port weirdness in DEC OSF/1? Date: 10 Mar 1994 23:20:43 GMT Organization: NCSA Message-ID: <2loa0b$sqk@vixen.cso.uiuc.edu> NNTP-Posting-Host: hoohoo.ncsa.uiuc.edu X-Newsreader: TIN [version 1.2 PL2] Hi, in the source for my information server, I need to find out what port a given socket is attached to while running under inetd. I'm finding that while my code to do this works elsewhere, it fails miserably under OSF/1, returning a very large integer (usually 20480 or 36895). Here is the code: int get_portnum(int sd,FILE *out) { struct sockaddr addr; int len; len = sizeof(struct sockaddr); if(getsockname(sd,&addr,&len) < 0) die(SERVER_ERROR,"could not get port number",out); return(((struct sockaddr_in *)&addr)->sin_port); } Does anyone see anything wrong with this? Is this a bug in OSF/1, or a mistake on my part which just happens to work on other systems? If it's an OS bug, does anyone have a workaround? This seems to happen with both OSF/1 1.2 and 1.3. -- Rob McCool, robm@ncsa.uiuc.edu Software Development Group, National Center for Supercomputing Applications It was working ten minutes ago, I swear... A must see.