On Mon, 22 Feb 2010, Xavi wrote: Hi Xavi,
> Okay. Well..., If it's not possible know the type of adapter > (Ethernet, Token Ring, ...) on other OS not Windows. :( It's is possible. Just like many other things which still do not exists in MS-Windows and we will have to wait next 10 years until MS discover them and add some support for it in WinSOCK.X.Y.Z which will work correctly in version X.Y.Z + N. There is only one question: Why we should add such things? The fact that sth is possible on some platforms does not mean that it has to be implemented. > #include "hbsocket.ch" > proc main( noAlias ) > local iface > ? os(), version() > ? "interfaces:" > for each iface in hb_inetIfInfo( !empty( noAlias ), 0 ) > ? "Family .... :", iface[HB_SOCKET_IFINFO_FAMILY] > ? "Name ...... :", iface[HB_SOCKET_IFINFO_NAME] > ? "Flags ..... :", iface[HB_SOCKET_IFINFO_FLAGS] > ? "Address ... :", iface[HB_SOCKET_IFINFO_ADDR] > ? "Mask ...... :", iface[HB_SOCKET_IFINFO_NETMASK] > ? "Bradcast .. :", iface[HB_SOCKET_IFINFO_BROADCAST] > ? "P2P ........:", iface[HB_SOCKET_IFINFO_P2PADDR] > ? "MAC ....... :", iface[HB_SOCKET_IFINFO_HWADDR] > ? "Gateway ... :", iface[HB_SOCKET_IFINFO_GATEWAY] > ? '-------------------------------------------------------' > next > ? > Wait > return Why you added HB_SOCKET_IFINFO_GATEWAY? What programs do you plan to write which will need such information? How do you know that which gateway belongs to each IP address? It's possible that aliases uses different gateways (at least in normal systems). I do not see any code which tries to bind gateway addresses with IP addresses so HB_SOCKET_IFINFO_GATEWAY contains correct information only when the same gateway is used by all aliases. MS-Windows does not have interface names as other hosts. AFAIR windows ports of some *nix tools like ifconfing used IP address as interface name so I decided to use the same. You added code which replace this IP addres with "localhost" string for LOOPBACK interfaces. Why? Do you know that it's possible to have more then one LOOPBACK interface with different addresses? You created exception with socket initialization for single function only. This code should be removed. We may decide to add automatic socket initialization to hbsocket.c code in the future but in such case it will have to be global feature not hacks in each single function. Now we have automatic initialization for HB_INET*() PRG functions and here the problem should be fixed. It's enough to add: HB_INET_INITIALIZE(); to HB_INETIFINFO() before hb_socketGetIFaces(). I'll commit the fix in a while. Thank you very much for information about the problem. hb_arrayGetC() returns address to dynamically allocated memory block which should be freed by hb_itemFreeC(). Now this code causes memory leak. Is iphlpapi.dll loaded by application at startup and keep alive for whole application running time? If not then storing pointer to GetAdaptersInfo() in static variable seems to be a little bit risk because such address may change. BTW in which Windows version GetAdaptersInfo() was added? This code does not detect aliases. It has to be redesigned to eliminate them. best regards, Przemek _______________________________________________ Harbour mailing list (attachment size limit: 40KB) [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
