I want to get the IP address of the network interface. There is both a wireless interface and a wired one. Is it possible, knowing the name of the network interface, to get its IP address?
Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 21, 2022 How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
April 21, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alexander Zhirov | On Thursday, 21 April 2022 at 07:04:18 UTC, Alexander Zhirov wrote: >I want to get the IP address of the network interface. There is both a wireless interface and a wired one. Is it possible, knowing the name of the network interface, to get its IP address?
|
April 21, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to dangbinghoo | On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote: >On Thursday, 21 April 2022 at 07:04:18 UTC, Alexander Zhirov wrote: >I want to get the IP address of the network interface. There is both a wireless interface and a wired one. Is it possible, knowing the name of the network interface, to get its IP address?
PS:
|
April 21, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to dangbinghoo | On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote: >On Thursday, 21 April 2022 at 07:04:18 UTC, Alexander Zhirov wrote: >I want to get the IP address of the network interface. There is both a wireless interface and a wired one. Is it possible, knowing the name of the network interface, to get its IP address?
Gives a lot of errors when compiling
|
April 22, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alexander Zhirov | On Thursday, 21 April 2022 at 07:38:04 UTC, Alexander Zhirov wrote: >On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote: >On Thursday, 21 April 2022 at 07:04:18 UTC, Alexander Zhirov wrote: >I want to get the IP address of the network interface. There is both a wireless interface and a wired one. Is it possible, knowing the name of the network interface, to get its IP address?
Gives a lot of errors when compiling
|
April 22, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to dangbinghoo | On Friday, 22 April 2022 at 05:28:52 UTC, dangbinghoo wrote: >On Thursday, 21 April 2022 at 07:38:04 UTC, Alexander Zhirov wrote: >[...]
[...] it's actually POSIX C API binding for D. you should get similar code in C when searching StackOverflow. the only thing to do this is just to look at /usr/include/dlang for POSIX API already complete binding from the official. if something is missing, you just do-it-yourself in your code. |
April 22, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to dangbinghoo | On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote: >[... Berkley sockets network code ...] It really makes me sad when I see this. D has some native networking API but unfortunately you have go to the OS API to have this basic functionality. D should really expand its own API so that we don't have to use OS APIs. |
April 22, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to IGotD- | On Fri, Apr 22, 2022 at 09:26:13AM +0000, IGotD- via Digitalmars-d-learn wrote: > On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote: > > > > [... Berkley sockets network code ...] > > > > It really makes me sad when I see this. D has some native networking API but unfortunately you have go to the OS API to have this basic functionality. D should really expand its own API so that we don't have to use OS APIs. [...] Why would you not want to use OS APIs? T -- Indifference will certainly be the downfall of mankind, but who cares? -- Miquel van Smoorenburg |
April 22, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | 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
2. Language APIs are usually much better to use that the OS APIs, like Berkeley sockets for example.
|
April 22, 2022 Re: How to get an IP address from network interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to IGotD- | 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". |