How to get an IP address from network interfaces

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Apr 22 19:30:15 UTC 2022


On Fri, Apr 22, 2022 at 03:46:01PM +0000, IGotD- via Digitalmars-d-learn wrote:
> On Friday, 22 April 2022 at 12:58:24 UTC, H. S. Teoh wrote:
> > 
> > Why would you not want to use OS APIs?
> > 
> 
> 1. Portability

Usually when portability matters, you already have specific OSes that
you're targeting, and probably already have your own OS compatibility
abstraction for them. If not, just make one, that translates whatever
internal API suits your code into per-OS calls.  D often makes this a
lot less painful than it could otherwise be.


> 2. Language APIs are usually much better to use that the OS APIs, like
> Berkeley sockets for example.

Depends on how the language API was designed. :-D  Some APIs are truly
nightmarish to use, some are nice but incur a performance overhead.  I
don't mind getting as close to OS API level as I can for performance,
then abstracting that layer into a nicer higher-level API that suits my
program's current needs.


T

-- 
Long, long ago, the ancient Chinese invented a device that lets them see through walls. It was called the "window".


More information about the Digitalmars-d-learn mailing list