🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #35376

Re: nnrpd daemon (-D) mode fixes

#35376
From: Russ Allbery
Date: Fri, 12 Feb 1999 00:00
31 lines
2153 bytes
bill davidsen <davidsen@tmr.com> writes:

> Then perhaps the prototype is wrong, since it requires sockaddr. If so,
> it's wrong on a LOT of systems... which is why I assumed that the
> prototype was correct and the source was wrong. If that's the case it's
> wrong on at least Linux, BSD, SCO and AIX, I checked there before I
> changed it.

It's been an axiom of writing socket code under Unix for many, many years
that you always have to cast your addresses to struct sockaddr when
passing them into network functions.

Solaris, IIRC, has recently done some header magic (which may or may not
work with compilers other than theirs) so that one doesn't get a warning
when passing in a struct sockaddr_in.  In my opinion, this just makes the
problem worse, since people then don't realize that will produce warnings
on other platforms.

The fundamental problem is that, in the standard network functions in the
C library, the socket address is actually something very akin to a
polymorphic object.  A C++ implementation would be able to resolve this
problem, since there would be a socket_address superclass, and ip_address,
ip6_address, unix_address, and the like would all inherit from it.  Then
you could let standard polymorphism handle this problem.

In C, you have to use C's version of polymorphism, which is typecasts.  :)

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Technical Details
Message-ID: <yl1zjuepcu.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <79eufj$7nh0$1@newssvr04-int.news.prodigy.com> <873e4kprj6.fsf@erlenstar.demon.co.uk> <79smvr$7ni8$1@newssvr04-int.news.prodigy.com> <79t2ms$iil$1@news1.epix.net> <7a1t47$8rka$1@newssvr04-int.news.prodigy.com>

Show Full Headers
Complete Article Headers
Message-ID: <yl1zjuepcu.fsf@windlord.stanford.edu>
Subject: Re: nnrpd daemon (-D) mode fixes
Date: Fri, 12 Feb 1999 00:00:00 +0000
From: Russ Allbery <rra@stanford.edu>
References: <79eufj$7nh0$1@newssvr04-int.news.prodigy.com> <873e4kprj6.fsf@erlenstar.demon.co.uk> <79smvr$7ni8$1@newssvr04-int.news.prodigy.com> <79t2ms$iil$1@news1.epix.net> <7a1t47$8rka$1@newssvr04-int.news.prodigy.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 443900686
Organization: The Eyrie
Newsgroups: news.software.nntp