It is very difficult for me to get information about Bluetooth connectivity in C ++. In particular, I want to avoid using third-party libraries, and I just want to connect to a device already connected to my computer.
The device has already entered its passcode and is available in the "Show Bluetooth devices" section under my devices and printers. I am using Windows 7 and visual studio 2013 for C ++ development.
I have an example code (from here http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancedotherprotocol4k.html ) that displays information about my Bluetooth radio and then displays information about the device and seems to work fine. Despite the fact that it prints every Bluetooth device that is already connected to the computer, and not those that are within the range, but it may be a misinterpretation of what the code should do.
I looked through the Bluetooth man page ( http://msdn.microsoft.com/en-us/library/windows/desktop/aa362930%28v=vs.85%29.aspx ) and all the functions are only related to setting up Bluetooth radio accessibility and other similar things; there are no signs of connecting to the detected device at all.
I need to miss something using the wrong keywords when using Google or something like that, because I did not find anything about connecting to a Bluetooth device!
If anyone has any suggestions, code or links that would be great! I can connect to my device using serial functionality (very easy), but I need to manually enter the COM port that it registered, which is not very convenient. I want to scan and select or enter the name of a Bluetooth device and connect in this way.
Greetings
EDIT:
BitBanks answers guided me in the right direction. The only thing missing was the WSAStartup request before any socket requests:
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(2, 2);
err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0) {
printf("WSAStartup failed with error: %d\n", err);
return 1;
}