// arm-linux-g++ -O2 -lbluetooth arm-listen.cpp -o arm-listen #include #include #include #include #include #include #include #include #include using namespace std; int main() { int sock, client; socklen_t alen; struct sockaddr_rc addr; str2ba("00:02:72:C3:26:F5", &addr.rc_bdaddr); addr.rc_family = AF_BLUETOOTH; addr.rc_channel = 5; alen = sizeof(addr); if((sock = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) { cout << "clientService: socket(...) failed" << endl; exit(1); } if(bind(sock, (struct sockaddr *)&addr, alen) < 0) { cout << "clientService: bind(...) failed" << endl; close(sock); exit(1); } if(listen(sock, 1) < 0) { cout << "clientService: listen(...) failed\n" << endl; exit(1); } client = accept(sock, (struct sockaddr *)&addr, &alen); cout << "connection here" << endl; close(client); close(sock); return 0; }