I'm trying to port a MacOSX app to windows and I've come up against a problem around getifaddrs. Basically windows does not support it. I'm trying to figure a way to re-implement it (for AF_INET and AF_INET6) but the "equivalent" functionality on windows appears to be nothing like the MacOSX support.
Has someone done this sort of conversion before? If so is there a nice way I can get windows to report me interface info like MacOSX does?
The closest functions on Windows are GetAdaptersInfo and GetAdaptersAddresses. The MSDN documentation is pretty comprehensive, so you should find everything you need.
getifaddrs() is not a portable solution, so if you need to support multiple platforms, you should consider using getaddrinfo, which is POSIX- and Windows-friendly. It is a little more complicated at first glance, but it really isn't that bad. This SO question has some good answers and links on the topic. (In particular, the showip.c example on Beej's page is quite helpful, and here is a Windows example; note that it is missing an #include <stdio.h> at the top, and be sure to link against Ws2_32.lib.)
I've done it here, including a separate version for Wine as the IP version agnostic routines don't current work as expected,
http://code.google.com/p/openpgm/source/browse/trunk/openpgm/pgm/getifaddrs.c
LGPL 2.1 license
edit: Wine 1.3 fixes the issues encountered with the IPv4 & IPv6 friendly API.
maybe win32 port of libpcap can help you?
(or port of libnet, if one exists)
Related
I am wondering how can I ask Windows and retrieve a list over current input devices?
Language is C++.
The goal is to select from the list in a program I am making.
Tried searching a bit, but found nothing..
Please help :)
Thank you.
For the sake of future reference, it might be worth mentioning the RtAudio library, which is also written in C++ and is multiplatform on Windows, OS-X and Linux.
On Windows you can compile it either using the ASIO SDK (in case your devices have an ASIO driver), DirectSound (part of DirectX, old and deprecated, but still working), or WASAPI (introduced in Windows Vista).
With RtAudio you can manage devices very easily with class method calls such as:
RtAudio::startStream();
RtAudio::stopStream();
RtAudio::getDeviceCount();
RtAudio::getDefaultInputDevice();
RtAudio::getDeviceInfo(uint deviceID);
You can also manage output devices in the same fashion.
This can be done through the WaveIn Windows API. Since there is already a post with code to enumarate and retrieve the names of input devices here I won't make a new one.
I am looking to communicate via RFCOMM to another Bluetooth device. I want to use C++ (VS2008) for the application. I already know of the 32feet library, but was unsure if it would work for C++. Does anyone know of a good starting point for this kind of project? Or possibly 32feet samples written in C++? I want a simple, easy to use API for Bluetooth using C++.
This question is rather old, I know.
Just wanted to update, that Qt Framework has now Qt Bluetooth for C++ that looks very promising -- http://doc.qt.io/qt-5/qtbluetooth-module.html
You can do Bluetooth programming using BT sockets into the OS Bluetooth stack. This page discusses socket usage:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa362928(v=vs.85).aspx
This page has links to download Bluetooth SDK from Microsoft:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363058(v=vs.85).aspx
Building apps using the Microsoft stack works fairly well (XP and Vista work great, trying to run the same apps under Windows 7-64bit does not work so well...)
The real advantage to 32feet.net is that the Bluetooth support on Windows is heavily Balkanized - you never know on a given machine whether it is using the Microsoft, Broadcom, Toshiba, BlueSolei, or some other stack. While these are all mostly compatible over-the-air, the APIs are completely different for each. Building with 32feet.net lets your application run on a larger subset of machines... That said, I have not tried building it into a C++ application - sorry.
I'm developing a PC c++ application running on windows. The application shall communicate with an android phone connected thru USB, using MTP. The idée is to not mount the Storage Card. What I have found is that Windows have something they call WPD (Windows Portable Device ) which supports MTP. It looks pretty ok but it demands WMP11 to be installed. What I wondering:
Is there are any other alternatives libraries you can use?
Do any one have any tips or experience about using WPD?
Are there any "leaner" dependencies you can install instead of WMP11 for xp?
Any help would be greatly appreciated.
I here provide some answers to my question for the hope that it will help some one else.
Is there any alternatives/leaner libraries?
You can use WIA but that is only used for images. but a part from that I have not found any.
Any tips?
Check out the sample code provided by Microsoft, it is a good start point. I found it be searching for Portable Devices COM API Sample on MSDN
For Services you can check out this sample code. Which I found by googling for WpdServicesApiSample
The WPD api is pretty ok to use.
Not all devices support MTP and some only support part of it. This caused me some problem but the device we used released an update which supported more of MTP
I found the answer about XP-problems from this StackOverflow by pcbbc really helpful. I can also add that we mailed the supplier and asked for a custom .INF file to support XP and they were really helpful and provided us with it. But it took some time before we got it.
I've tried to find a way to detect when a new device (like a USB) is inserted into a computer, but everything I've seen required MFC, which I don't have. Is there a way to do this without MFC? If not, I understand, but I haven't seen anything of the like in my Google searches.
Thanks,
C++ by itself does not have any platform-dependent hardware-level functionality. You will need to use some API, like Win32 or MFC or .NET on Windows.
You can do this using libusb and there's a port of libusb for win32, so you might have some luck using that instead of MFC, with the added bonus of being more portable.
Handle the WM_DEVICECHANGE message.
See http://msdn.microsoft.com/en-us/library/aa363480(v=vs.85).aspx
EDIT: Of course, this is Windows only, which the OP didn't specify. There's no way to do this without external libraries or platform specific APIs.
I have emailed Entrek and they seem to be asleep.
Does anyone else here use Entrek CodeSnitch? If so, have you found a way to use it with Windows Mobile 5, 6, or 6.1 ?
I really need to verify my application doesn't have any memory leaks, etc. And CodeSnitch does a great job of it. But only with Windows Mobile 2003. :/
Thanks.
What's not working? Is it a client connectivity issue?
The older version used PlatMan for a communications layer, which is problematic from a Visual Studio standpoint (which ships with CoreCon), but if you have any tool installed that has Platman (eVC, Platform Builder) then that should still work fine since WinMo 5.x and 6.x are still based on CE 5.0.
I do know that Entrek has a newer version in beta (I have it) so you might try pinging them again. They tend to be pretty busy, but I've always gotten responses (though I know them well and personally, so that might not be any indicator for you).
I also see that they have their phone number posted on their web page. I'd give them a call. I do recall them saying the new version is supposed to address WinMo issues (I rarely use WinMo proper) so it's definitely worth a try.
I've not used CodeSnitch. But I have had success using the Application Verifier Tool to identify my leaks in WM5 and 6.
Getting it up and running can be a bit of a pain. But I find it to be a good tool and the price is right.
Here's a tutorial to get you started.
I've used CodeSnitch on windows mobile 5, 6 and 6.1 devices with no problems.
Make sure you have the v1.4 installed and applied the v1.4 patch which is referenced here.
Like ctackle says, you need an older communications layer called CoreCon. I've also found CETK has CoreCon in it as well and it's not as big as eVC or Platform builder.
You need to setup the device connection settings to use ActiveSync (both transport and startup server), it does not seem to matter what the connection is called so something like Pocket PC will work fine.
The other gotcha I found is that you need to edit the codesnitch and procman shortcuts and add "/targetcpu:armv4i" to the command line arguments for them to work on WM devices.
I have also found them recently to be non-responsive to support emails as well :(