Click here to Skip to main content
15,887,301 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Pointer to member function in struct Pin
Chang Su Lee24-Aug-11 5:29
Chang Su Lee24-Aug-11 5:29 
GeneralRe: Pointer to member function in struct Pin
Richard MacCutchan24-Aug-11 6:09
mveRichard MacCutchan24-Aug-11 6:09 
GeneralRe: Pointer to member function in struct Pin
Dean Seo22-Aug-11 21:27
Dean Seo22-Aug-11 21:27 
QuestionIDE from programm in C++ Pin
Chargoy22-Aug-11 16:04
Chargoy22-Aug-11 16:04 
AnswerRe: IDE from programm in C++ Pin
Richard Andrew x6422-Aug-11 16:13
professionalRichard Andrew x6422-Aug-11 16:13 
AnswerRe: IDE from programm in C++ PinPopular
Albert Holguin22-Aug-11 16:40
professionalAlbert Holguin22-Aug-11 16:40 
GeneralRe: IDE from programm in C++ Pin
Chargoy27-Aug-11 5:43
Chargoy27-Aug-11 5:43 
QuestionHandle bluetooth pairing code Pin
Vijay Rajanna22-Aug-11 7:15
Vijay Rajanna22-Aug-11 7:15 
Hi,

I'm using windows 7 pc, and trying to write a Bluetooth server app.

My requirement is to pair my Mobile (Nokia -N8) with my server app, and then exchange data using a service class.

ISSUE:

The issue I'm facing is, on running server on my PC, the server waits for connection request from phone.

But phone is asking me to enter a pass code, But i don't know how to handle this passcode issue at server side. and establish the connection.

The connection always fails with a message that no response from server.



Here is my server code, which I'm running on my win 7 PC.

// Bluetooth.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <winsock2.h>
#include <ws2bth.h>
#include <bthsdpdef.h>
#include <bluetoothapis.h>

#pragma comment(lib, "Ws2_32.lib")


int _tmain(int argc, _TCHAR* argv[])
{
//----------------------
// Initialize Winsock.
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != NO_ERROR)
{
wprintf(L"WSAStartup failed with error: %ld\n", iResult);
return 1;
}

//----------------------
// Create a SOCKET for listening for
// incoming connection requests.
SOCKET ListenSocket;
ListenSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
if (ListenSocket == INVALID_SOCKET) {
wprintf(L"socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return 1;
}

//----------------------
// The sockaddr_in structure specifies the address family,
// IP address, and port for the socket that is being bound.
SOCKADDR_BTH blthsocket;
memset(&blthsocket,0,sizeof(SOCKADDR_BTH));

blthsocket.addressFamily = AF_BTH;
blthsocket.btAddr = 0;
blthsocket.serviceClassId = GUID_NULL;
blthsocket.port = BT_PORT_ANY ;

wprintf(L"============ Before Bind =============\n");
wprintf(L"blthsocket.btAddr = %d \n",blthsocket.btAddr);
wprintf(L"blthsocket.port = %d \n",blthsocket.port);


if (bind(ListenSocket,(SOCKADDR *) & blthsocket, sizeof (blthsocket)) == SOCKET_ERROR)
{
wprintf(L"bind failed with error: %ld\n", WSAGetLastError());
closesocket(ListenSocket);
WSACleanup();
return 1;
}

wprintf(L"Binding is complete\n");
wprintf(L"\n\n============ After Bind =============\n");
int len = sizeof(blthsocket);
if (0 == getsockname (ListenSocket, (sockaddr*)&blthsocket, &len))
{
wprintf (L"Local Bluetooth device is %04x%08x \nServer channel = %d\n",
GET_NAP(blthsocket.btAddr), GET_SAP(blthsocket.btAddr), blthsocket.port);
}

//----------------------------------------------------------------------------
wprintf(L"Waiting for client to connect...\n");
listen (ListenSocket, 5);
for ( ; ; ) {
SOCKADDR_BTH sab2;
int ilen = sizeof(sab2);
SOCKET s2 = accept (ListenSocket,(sockaddr*)&sab2, &ilen);
if (s2 == INVALID_SOCKET) {
wprintf (L"Socket bind, error %d\n", WSAGetLastError ());
break;
}
wprintf (L"Connection came from %04x%08x to channel %d\n",
GET_NAP(sab2.btAddr), GET_SAP(sab2.btAddr), sab2.port);
wprintf (L"Hello");
SpinConnectionThreadsOnSocket (s2);
}
closesocket (ListenSocket);
WSACleanup();
return 0;
}



Kindly help resolving this issue, Thanks in advance.

Regards,

Vijay.
AnswerRe: Handle bluetooth pairing code Pin
«_Superman_»22-Aug-11 8:47
professional«_Superman_»22-Aug-11 8:47 
QuestionVC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup [modified] Pin
cgb14322-Aug-11 6:43
cgb14322-Aug-11 6:43 
AnswerRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
Code-o-mat22-Aug-11 7:46
Code-o-mat22-Aug-11 7:46 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
cgb14322-Aug-11 9:12
cgb14322-Aug-11 9:12 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
Code-o-mat22-Aug-11 9:40
Code-o-mat22-Aug-11 9:40 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
xrg_soft@163.com23-Aug-11 5:37
xrg_soft@163.com23-Aug-11 5:37 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
cgb14323-Aug-11 6:28
cgb14323-Aug-11 6:28 
GeneralRe: VC6 C++ can I prevent an "Internet Explorer Script Error" debug dialog popup Pin
xrg_soft@163.com23-Aug-11 21:47
xrg_soft@163.com23-Aug-11 21:47 
QuestionDisabling the 'Alt' key Pin
Malli_S22-Aug-11 2:29
Malli_S22-Aug-11 2:29 
AnswerRe: Disabling the 'Alt' key Pin
Hans Dietrich22-Aug-11 7:25
mentorHans Dietrich22-Aug-11 7:25 
GeneralRe: Disabling the 'Alt' key Pin
Malli_S22-Aug-11 19:32
Malli_S22-Aug-11 19:32 
GeneralRe: Disabling the 'Alt' key Pin
JohnNawrocki23-Aug-11 3:58
JohnNawrocki23-Aug-11 3:58 
GeneralRe: Disabling the 'Alt' key Pin
Rage24-Aug-11 4:26
professionalRage24-Aug-11 4:26 
GeneralRe: Disabling the 'Alt' key Pin
Malli_S24-Aug-11 22:09
Malli_S24-Aug-11 22:09 
QuestionStrange Problem Pin
john563221-Aug-11 17:52
john563221-Aug-11 17:52 
AnswerRe: Strange Problem Pin
Richard MacCutchan21-Aug-11 21:34
mveRichard MacCutchan21-Aug-11 21:34 
GeneralRe: Strange Problem Pin
john563221-Aug-11 23:11
john563221-Aug-11 23:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.