Hi all,
I'd like to get, in a portable way, a list of all
network adapters on a local machine running some
python code.
socket.gethostn ame() does not seem enough, as it
only returns one name ; I'd like to get all
available IPs.
I could process ipconfig or ifconfig outputs, but
this is OS-dependant and not very future-proof...
Best regards,
Olivier Parisy. 7 4129
> I could process ipconfig or ifconfig outputs, but this is OS-dependant and not very future-proof...
This has been discussed quite a few times on this NG, search google groups.
However IMHO there is no general system built-in way (AFAIK not even posix)
for doing this, you'll end up parsing tool output anyway...
--
Regards,
Diez B. Roggisch
Diez B. Roggisch wrote: This has been discussed quite a few times on this NG, search google groups. However IMHO there is no general system built-in way (AFAIK not even posix) for doing this, you'll end up parsing tool output anyway...
I should have done this first, my mistake...
But actually, a previously posted message suggests a portable way to get
the platform IPs. Citing John Abel :
socket.gethostb yaddr( socket.gethostn ame() ) will return all the details that you need to know. For example, the output of that command on my machine is :
('hallows', [], ['101.101.101.10 2', '10.253.1.118'])
Are there some pitfalls I'm not aware of ?
Thanks,
Olivier Parisy.
Olivier Parisy wrote:
[snip] But actually, a previously posted message suggests a portable way to get the platform IPs. Citing John Abel :
> socket.gethostb yaddr( socket.gethostn ame() ) will return all the > details that you need to know. For example, the output of that > command on my machine is : > > ('hallows', [], ['101.101.101.10 2', '10.253.1.118'])
Are there some pitfalls I'm not aware of ?
Doesn't seem to work right on Windows, for me at least: socket.gethostb yaddr(socket.ge thostname())
('<my machine name>', [], ['169.254.0.100'])
It returned the least useful of my 3 IP addresses - my loopback adapter
- but didn't return my LAN and wireless IPs.
-Dave
Dave Brueck <da**@pythonapo crypha.com> writes: Olivier Parisy wrote: [snip] But actually, a previously posted message suggests a portable way to get the platform IPs. Citing John Abel : > socket.gethostb yaddr( socket.gethostn ame() ) will return all the > details that you need to know. For example, the output of that > command on my machine is : > > ('hallows', [], ['101.101.101.10 2', '10.253.1.118']) Are there some pitfalls I'm not aware of ?
Doesn't seem to work right on Windows, for me at least:
>>> socket.gethostb yaddr(socket.ge thostname())
('<my machine name>', [], ['169.254.0.100'])
It returned the least useful of my 3 IP addresses - my loopback adapter - but didn't return my LAN and wireless IPs.
If anyone really needs it, I can post code for windows using ctypes to
collect ip-addresses and netmasks together with the name and description
of all network adapters.
Thomas
> > It returned the least useful of my 3 IP addresses - my loopback adapter - but didn't return my LAN and wireless IPs.
Interesting! I have Python installed on 10 W2K servers and I'm using
the same construct to get addresses. Works fine for me.
Elbert Lev wrote: It returned the least useful of my 3 IP addresses - my loopback adapter - but didn't return my LAN and wireless IPs.
Interesting! I have Python installed on 10 W2K servers and I'm using the same construct to get addresses. Works fine for me.
WinXP Pro here - I wonder if that's the difference.
-Dave
Dave Brueck wrote: Elbert Lev wrote:
It returned the least useful of my 3 IP addresses - my loopback adapter - but didn't return my LAN and wireless IPs. Interesting! I have Python installed on 10 W2K servers and I'm using the same construct to get addresses. Works fine for me.
WinXP Pro here - I wonder if that's the difference.
Interestingly, I have the same problem with XP Pro.
But socket.gethostb yname_ex seems to do the trick for me !
Regards,
Olivier. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gordon Knote |
last post by:
Hi
how can I enumerate (and get information about) all installed network adapters on a local machine (in .net)
Thanks a lo
Gordon
|
by: LK |
last post by:
Can PLEASE SOMEONE HELP me how to enumerate local network interfaces (i.e ip
addresses, dns, etc.) with csharp.
I need the type of information that would come up when typing
ipconfig /all
at a command prompt.
Thank you soo much
|
by: Michael C |
last post by:
Hi all,
After a lot of research, I've come to some realizations about enumerating
Named Instances of MSDE. NetServerEnum() Win32 API function doesn't work,
SQL-DMO doesn't work, no standard routines seem to work. SQL-DMO is by far
the most robust solution - since it calls NetServerEnum() first, and
subsequently sends out a broadcast on Port 1433 to locate all SQL Servers on
the network. This does pick up all default instances (as long...
|
by: Maniaque |
last post by:
Does anybody knows, how can I address multiply network adapters on one
computer?
I've looked up through classes reference and found nothing.
Thanks in advance.
--
.... blood, sugar, sex, magic ...
|
by: Glenn Leifheit |
last post by:
Does anyone have any sample code on enumerating network shares with vb.net.
I here you need to use wither an API or WMI, or are there other
recomendations.
Thanks
Glenn
| |
by: Joe User |
last post by:
Hi - I found the class below on another website (www.devx.com)
and can't seem to figure out how to make a call to this class to
retrieve the machines and put them in a listbox.
I am definitely a beginner in vb programming, and would really
appreciate the help.
TIA!
|
by: Phil Galey |
last post by:
Is there any way of enumerating all printers, including network printers in VB.NET?
printing.PrinterSettings.InstalledPrinters only enumerates printers attached to the local workstation. Thanks.
|
by: amir |
last post by:
Hello All,
I am currently looking for writing an application that will act like
a
network bridge. Meaning, I have 2 network adapters and i want all
thing
from 1 adapter will pass directly to the other adapter (both ways).
Wandered
if anyone has written something like that, or can tell me where to
read about it, or maybe c# has a simple class for accesing network
adapters and doing those connectios.
|
by: =?Utf-8?B?TWFydGlu?= |
last post by:
In Device Manager under Network Adapters, nearly all (about 20) items have a
yellow warning symbol. The first item, Microsoft 6to4 Adapter says driver is
up-to-date BUT says "This device is not working properly because Windows
cannot load the drivers required for their device (Code 31). Similar message
in all other 20 items under network adapters. Have checked for solutions -
send data to Micosoft- but so far no solutions. Any help please?...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |