Hello there,
This is the first time I'm probramming for bluetooth.
I installed a USB bluetooth device and the software comes with it works
great, detecting other devices and communicates.
Now I'm developing an bluetooth application to run in server mode (using
WSASetService).
But it fails at bind() with WSANETDOWN. Any idea how to troubleshoot this ??
Platform: WindowsXp-SP2, MSVC6
SOCKET s = ::socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
DWORD lastError = ::WSAGetLastError();
if (s == INVALID_SOCKET)
{
printf("Failed to get bluetooth socket! %s\n",
GetLastErrorMessage(lastError));
exit(1);
}
SOCKADDR_BTH sbth;
memset(&sbth, 0, sizeof(sbth));
sbth.addressFamily = AF_BTH;
sbth.btAddr = 0;
sbth.port = BT_PORT_ANY;
if (bind(s, (const sockaddr*)&sbth, sizeof(SOCKADDR_BTH)) == SOCKET_ERROR)
// <<------ here is the problem
{
lastError = ::WSAGetLastError(); // always WSANETDOWN
printf("Failed to bind bluetooth socket! %s\n",
GetLastErrorMessage(lastError));
exit(1);
}
|