On Thu, Aug 11, 2005 at 05:45:10PM +0200, Alexander Farber wrote: > 2005/8/11, Henning Brauer <[EMAIL PROTECTED]>: > > sockaddr_in would suffice, but it is bad style. with sockaddr_storage, > > you ar eon the safe side, even when you add v6 support later, or v8, or > > whatever the future brings, so play safe and use sockaddr_storage, > > that's what it is for. > > Thanks. Yes, I don't want my server to crash when accepting > some manipulated packets, so I will use sockaddr_storage. > (I just didn't want to do something too stupid, that's why I asked) >
Accept will only return valid data and will not overflow the sockaddr passed (that's why you have to pass the length to accept). Also an AF_INET socket will never return something else then a sockaddr_in. Using sockaddr_storage has a benefit in so far that it helps to port the application to any other address family. In that case you know that at least the accept() call is save, the question is what you do afterwards with the passed address. -- :wq Claudio

