0

I wrote a Bluetooth client program for a wince 4.2 device. The device discovery works fine. However, when I attempt to connect to a PC, the connect function immediately returns with error code 10053. The connection request was being processed by the PC with a prompt to enter the authentication code but the wince device doesn’t seem to wait.

What could be causing this issue? I am using the following steps (removed error handling for simplicity):

WSAStartup(..)…////was successful.

SOCKET m_Socket =Socket (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); //was successful.

SOCKADDR_BTH sClinet;
memset (&sClinet, 0, sizeof(sClinet));
sClinet.addressFamily = AF_BTH;
sClinet.btAddr = btd.btaddr; ; //BT_ADDR of the PC obtained via Device Discovery..
sClinet.port = BT_PORT_ANY; //I did try 0, did not help!
sClinet.serviceClassId = RFCOMM_PROTOCOL_UUID; 

int nConErr = connect (m_Socket, (SOCKADDR *)&sClinet, sizeof(sClinet));

nConErr returns 10053 immediately. It doesn’t even wait, even though the PC recognized the connection and prompted a message to enter the PIN for authentication.

ObscureRobot
  • 7,306
  • 2
  • 27
  • 36

1 Answers1

0

From what you are describing it looks like it is a pairing/authentication problem. You should consider in using also setsockopt function: http://msdn.microsoft.com/en-us/library/ms863347.aspx

You should try to use SO_BTH_AUTHENTICATE option which according to MSDN:

On connected socket, triggers authentication. On not connected socket, forces authentication on connection. For incoming connection this means that connection is rejected if authentication cannot be performed.

So before calling connect function you should set options to your socket.

garzanti
  • 2,162
  • 1
  • 22
  • 30