sock_shutdown_bug_rfcomm.c revision 10d31b957a35d4ac084be33b0f136568039c9c14
110d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly/* 210d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** Copyright 2009 The Android Open Source Project 310d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** 410d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** Licensed under the Apache License, Version 2.0 (the "License"); 510d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** you may not use this file except in compliance with the License. 610d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** You may obtain a copy of the License at 710d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** 810d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** http://www.apache.org/licenses/LICENSE-2.0 910d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** 1010d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** Unless required by applicable law or agreed to in writing, software 1110d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** distributed under the License is distributed on an "AS IS" BASIS, 1210d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1310d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** See the License for the specific language governing permissions and 1410d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly** limitations under the License. 1510d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly*/ 1610d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly 1710d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly#include <stdio.h> 1810d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly#include <stdlib.h> 1910d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly#include <unistd.h> 2010d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly#include <sys/socket.h> 2110d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly#include <fcntl.h> 2210d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly 2310d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly#include <bluetooth/bluetooth.h> 2410d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly#include <bluetooth/rfcomm.h> 2510d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly 2610d31b957a35d4ac084be33b0f136568039c9c14Nick Pellyint main(int argc, char **argv) { 2710d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly int fd; 2810d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly int ret; 2910d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly long flags; 3010d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly struct sockaddr_rc addr; 3110d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly 3210d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly addr.rc_family = AF_BLUETOOTH; 3310d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly addr.rc_channel = 19; 3410d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly str2ba("00:17:E8:2C:A8:00", &addr.rc_bdaddr); 3510d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly 3610d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); 3710d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly flags = fcntl(fd, F_GETFL); 3810d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly fcntl(fd, F_SETFL, flags | O_NONBLOCK); 3910d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly 4010d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly connect(fd, (struct sockaddr *)&addr, sizeof(addr)); 4110d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly 4210d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly sleep(2); 4310d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly shutdown(fd, SHUT_RDWR); 4410d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly sleep(2); 4510d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly close(fd); 4610d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly return 0; 4710d31b957a35d4ac084be33b0f136568039c9c14Nick Pelly} 48