Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!worldnet.att.net!newsadm
From: Michael DeVivio <omc@worldnet.att.net>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Simple Socket Question?
Date: Wed, 22 Jan 1997 17:09:32 -0500
Organization: Online Multimedia Communications, Inc.
Lines: 51
Message-ID: <32E6901C.416@worldnet.att.net>
References: <32E67E89.7CA4@worldnet.att.net>
Reply-To: omc@worldnet.att.net
NNTP-Posting-Host: 207.116.38.220
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.01Gold (Win95; I)
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:34370
Michael DeVivio wrote:
>
> Hello,
>
> I am new to UNIX and have had good success running PERL scripts like
> message boards, shopping carts, etc. I recently tried to put a web
> interface for Usenet news articals. The program is called Forum News
> Gateway. Here is my problem. When I open the socket like this:
>
> perl httpd.pl 8888&
>
> everything seems ok. It says it is listening. Then when I try to access
> that port through the client, I get this error:
>
> In RemoteGetIPAddr: socket is not an AF_INETsocket!
> Connection rejected: can't get remote IP number
>
> Why can't it figure out this IP number? I see quite a few sites on the
> net that got this thing to run. I am using BSD UNIX.
>
> Please reply to omc@worldnet.att.net
>
> Thank you in advance for your reply.
>
> Michael
>
> P.S. How do I close these sockets so I can try them again. If I repeat
> the process I can't use the same port number.
Here is the code thats failing, I think:
# GetRemoteIPNum($FileHandle)
# Return the IP number of the machine on the other end of the given TCP
connection.
# Return "" if there's an error.
sub GetRemoteIPNum {
local($FileHandle) = @_;
local($That) = getpeername($FileHandle);
return "" if ($That eq ""); # if getpeername failed
local($Family,$Port,$RemoteAddr) = unpack($TCPSockAddr,$That);
if ($Family != &AF_INET) {
print STDERR "In GetRemoteIPAddr: socket is not an AF_INET socket!\n";
return "";
}
return $RemoteAddr;
}