Hello,
I've been trying to develop a simple client/server application that uses the bluetooth USB dongles of 2 PCs using windows sockets and the bluetooth support provided in the windows platform SDK
I can create the sockets fine, but when I go to invoke "bind" or "connect", the program spits out the error code 10050 (network is down/dead), but I can't figure out where the problem is or what is causing it (everywhere on the net is very vague about this error)
Any ideas?
Thanks
I am including a portion of my code up until when the program exits
#include <winsock2.h>
#include <ws2bth.h>
#include <BluetoothAPIs.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "irprops.lib")
using namespace std;
int main()
{
//Initialising winsock
WSADATA data;
int result;
result = WSAStartup(MAKEWORD(2, 2), &data);//initializing winsock
if (result!=0)
{
cout << "An error occured while initialising winsock, closing....";
exit(result);
}
SOCKET s = socket (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
if (s == INVALID_SOCKET)
{
wprintf (L"Socket creation failed, error %d\n", WSAGetLastError ());
return 0;
}
SOCKADDR_BTH sab;
memset (&sab, 0, sizeof(sab));
sab.addressFamily = AF_BTH;
sab.port = BT_PORT_ANY;
if (0 != bind (s, (struct sockaddr *) &sab, sizeof(SOCKADDR_BTH)))
{
wprintf (L"Socket bind, error %d\n", WSAGetLastError ());
closesocket (s);
return 0;
}
The error occurs at "Socket bind, error"
I should also add that hte bluetooth usb dongles have been tested and work, and I'm running all this on windows XP with SP2, and using visual studio 2005 team suite