当前位置: 首页>>代码示例>>C++>>正文


C++ sdp_close函数代码示例

本文整理汇总了C++中sdp_close函数的典型用法代码示例。如果您正苦于以下问题:C++ sdp_close函数的具体用法?C++ sdp_close怎么用?C++ sdp_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sdp_close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create_search_context

static int create_search_context(struct search_context **ctxt,
					const bdaddr_t *src,
					const bdaddr_t *dst,
					uuid_t *uuid)
{
	sdp_session_t *s;
	GIOChannel *chan;

	if (!ctxt)
		return -EINVAL;

	s = get_sdp_session(src, dst);
	if (!s)
		return -errno;

	*ctxt = g_try_malloc0(sizeof(struct search_context));
	if (!*ctxt) {
		sdp_close(s);
		return -ENOMEM;
	}

	bacpy(&(*ctxt)->src, src);
	bacpy(&(*ctxt)->dst, dst);
	(*ctxt)->session = s;
	(*ctxt)->uuid = *uuid;

	chan = g_io_channel_unix_new(sdp_get_socket(s));
	(*ctxt)->io_id = g_io_add_watch(chan,
				G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
				connect_watch, *ctxt);
	g_io_channel_unref(chan);

	return 0;
}
开发者ID:Xperia-Nicki,项目名称:android_platform_sony_nicki,代码行数:34,代码来源:glib-helper.c

示例2: bt_cancel_discovery

int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst)
{
	struct search_context search, *ctxt;
	GSList *match;

	memset(&search, 0, sizeof(search));
	bacpy(&search.src, src);
	bacpy(&search.dst, dst);

	/* Ongoing SDP Discovery */
	match = g_slist_find_custom(context_list, &search, find_by_bdaddr);
	if (!match)
		return -ENODATA;

	ctxt = match->data;
	if (!ctxt->session)
		return -ENOTCONN;

	if (ctxt->io_id)
		g_source_remove(ctxt->io_id);

	if (ctxt->session)
		sdp_close(ctxt->session);

	search_context_cleanup(ctxt);
	return 0;
}
开发者ID:Mcjesus15,项目名称:Zio_Other,代码行数:27,代码来源:glib-helper.c

示例3: bt_cancel_discovery

int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst)
{
	struct search_context match, *ctxt;
	GSList *l;

	memset(&match, 0, sizeof(match));
	bacpy(&match.src, src);
	bacpy(&match.dst, dst);

	/* Ongoing SDP Discovery */
	l = g_slist_find_custom(context_list, &match, find_by_bdaddr);
	if (l == NULL)
		return -ENOENT;

	ctxt = l->data;

	if (!ctxt->session)
		return -ENOTCONN;

	delete_cached_session(ctxt->session);

	if (ctxt->io_id)
		g_source_remove(ctxt->io_id);
	ctxt->io_id = 0;

	if (ctxt->session)
		sdp_close(ctxt->session);
	ctxt->session = NULL;

	search_context_cleanup(ctxt);

	return 0;
}
开发者ID:Xperia-Nicki,项目名称:android_platform_sony_nicki,代码行数:33,代码来源:glib-helper.c

示例4: DBG

static sdp_session_t *service_connect(const bdaddr_t *src, const bdaddr_t *dst,
					GIOFunc function, gpointer user_data)
{
	struct bluetooth_session *session = user_data;
	sdp_session_t *sdp;
	GIOChannel *io;

	DBG("");

	sdp = sdp_connect(src, dst, SDP_NON_BLOCKING);
	if (sdp == NULL)
		return NULL;

	io = g_io_channel_unix_new(sdp_get_socket(sdp));
	if (io == NULL) {
		sdp_close(sdp);
		return NULL;
	}

	g_io_add_watch(io, G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
							function, user_data);

	session->io = io;

	return sdp;
}
开发者ID:ghent360,项目名称:bluez,代码行数:26,代码来源:bluetooth.c

示例5: cfg_query

prop_dictionary_t
cfg_query(bdaddr_t *laddr, bdaddr_t *raddr, const char *service)
{
	prop_dictionary_t dict;
	sdp_session_t ss;
	size_t i;

	dict = prop_dictionary_create();
	if (dict == NULL)
		err(EXIT_FAILURE, "prop_dictionary_create()");

	for (i = 0; i < __arraycount(cfgtype); i++) {
		if (strcasecmp(service, cfgtype[i].name) == 0) {
			ss = sdp_open(laddr, raddr);
			if (ss == NULL)
				err(EXIT_FAILURE, "SDP connection failed");

			if (!cfg_search(ss, i, dict))
				errx(EXIT_FAILURE, "service %s not found", service);

			sdp_close(ss);
			return dict;
		}
	}

	printf("Known config types:\n");
	for (i = 0; i < __arraycount(cfgtype); i++)
		printf("\t%s\t%s\n", cfgtype[i].name, cfgtype[i].description);

	exit(EXIT_FAILURE);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:31,代码来源:sdp.c

示例6: search_process_cb

static gboolean search_process_cb(GIOChannel *chan, GIOCondition cond,
							gpointer user_data)
{
	struct search_context *ctxt = user_data;
	int err = 0;

	if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
		err = EIO;
		goto failed;
	}

	if (sdp_process(ctxt->session) < 0)
		goto failed;

	return TRUE;

failed:
	if (err) {
		sdp_close(ctxt->session);
		ctxt->session = NULL;

		if (ctxt->cb)
			ctxt->cb(NULL, err, ctxt->user_data);

		search_context_cleanup(ctxt);
	}

	return FALSE;
}
开发者ID:Xperia-Nicki,项目名称:android_platform_sony_nicki,代码行数:29,代码来源:glib-helper.c

示例7: bt_clear_cached_session

void bt_clear_cached_session(const bdaddr_t *src, const bdaddr_t *dst)
{
	sdp_session_t *session;

	session = get_cached_sdp_session(src, dst);
	if (session)
		sdp_close(session);
}
开发者ID:MDomagala,项目名称:bluez,代码行数:8,代码来源:sdp-client.c

示例8: sdpreg_cleanup

void sdpreg_cleanup(void)
{
	if (srvHandle < 0)
		return;
	sdp_close(srvHandle);
	sdp_cleanup();
	srvHandle = -1;
}
开发者ID:github188,项目名称:SimpleCode,代码行数:8,代码来源:btsrv-sdp.c

示例9: sdp_remove

void sdp_remove()
{
	if (sdp_record && sdp_record_unregister(sdp_session, sdp_record)) {
		printf("%s: HID Device (Keyboard) Service Record unregistration failed\n", (char*)__func__);
	}
	
	sdp_close(sdp_session);
}
开发者ID:kim0051,项目名称:HIDSlave,代码行数:8,代码来源:sdp.c

示例10: dun_sdp_search

int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int type)
{
	sdp_session_t *s;
	sdp_list_t *srch, *attrs, *rsp;
	uuid_t svclass;
	uint16_t attr;
	int err;

	s = sdp_connect(src, dst, 0);
	if (!s) {
		syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)", 
				strerror(errno), errno);
		return -1;
	}

	switch (type) {
	case MROUTER:
		sdp_uuid16_create(&svclass, SERIAL_PORT_SVCLASS_ID);
		break;
	case ACTIVESYNC:
		sdp_uuid128_create(&svclass, (void *) async_uuid);
		break;
	case DIALUP:
		sdp_uuid16_create(&svclass, DIALUP_NET_SVCLASS_ID);
		break;
	default:
		sdp_uuid16_create(&svclass, LAN_ACCESS_SVCLASS_ID);
		break;
	}

	srch  = sdp_list_append(NULL, &svclass);

	attr  = SDP_ATTR_PROTO_DESC_LIST;
	attrs = sdp_list_append(NULL, &attr);

	err = sdp_service_search_attr_req(s, srch, SDP_ATTR_REQ_INDIVIDUAL, attrs, &rsp);

	sdp_close(s);

	if (err)
		return 0;

	for(; rsp; rsp = rsp->next) {
		sdp_record_t *rec = (sdp_record_t *) rsp->data;
		sdp_list_t *protos;

		if (!sdp_get_access_protos(rec, &protos)) {
			int ch = sdp_get_proto_port(protos, RFCOMM_UUID);
			if (ch > 0) {
				*channel = ch;
				return 1;
			}
		}
	}

	return 0;
}
开发者ID:0omega,项目名称:platform_external_bluez,代码行数:57,代码来源:sdp.c

示例11: sess_dealloc

static void
sess_dealloc(PySDPSessionObject *s)
{
    if(s->session != NULL) {
        sdp_close( s->session );
        s->session = NULL;
    }
    s->ob_type->tp_free((PyObject *)s);
}
开发者ID:Why7090,项目名称:python-for-android,代码行数:9,代码来源:btsdp.c

示例12: main

int main(int argc, char const *argv[])
{
	uint32_t svc_uuid_int[] = {0, 0, 0, 0xABCD};
	int status;
	bdaddr_t target, source;
	uuid_t svc_uuid;
	sdp_list_t *response_list, *search_list, *attrid_list;
	sdp_session_t *session = 0;
	uint32_t range = 0x0000ffff;
	uint8_t port = 0;


	//connect to the SDP server running on the remote machine
	str2ba(dest, &target);
	str2ba(src, &source);

	session = sdp_connect(&source, &target, 0);
	if (session == NULL) {
		perror("sdp_connect");
		exit(1);
	}

	sdp_uuid128_create(&svc_uuid, &svc_uuid_int);
	search_list = sdp_list_append(0, &svc_uuid);
	attrid_list = sdp_list_append(0, &range);

	//get a list of service records that have UUID 0xabcd
	response_list = NULL;
	status = sdp_service_search_attr_req(session, search_list, SDP_ATTR_REQ_RANGE, attrid_list, &response_list);
	if (status == 0) {
		sdp_list_t *proto_list = NULL;
		sdp_list_t *r = response_list;

		//go through each of the service records
		for (; r; r = r->next) {
			sdp_record_t *rec = (sdp_record_t *)r->data;

			//get a list of the protocol sequences
			if (sdp_get_access_protos(rec, &proto_list) == 0) {
				// get the RFCOMM port number
				port = sdp_get_proto_port(proto_list, RFCOMM_UUID);
				sdp_list_free(proto_list, 0);
			}
			sdp_record_free(rec);
		}
	}
	sdp_list_free(response_list, 0);
	sdp_list_free(search_list, 0);
	sdp_list_free(attrid_list, 0);
	sdp_close(session);

	if (port != 0) {
		printf("found service running on RFCOMM Port %d\n", port);
	}

	return 0;
}
开发者ID:lsyslsy,项目名称:SEMG,代码行数:57,代码来源:discover-client.c

示例13: connect_watch

static gboolean connect_watch(GIOChannel *chan, GIOCondition cond,
							gpointer user_data)
{
	struct search_context *ctxt = user_data;
	sdp_list_t *search, *attrids;
	uint32_t range = 0x0000ffff;
	socklen_t len;
	int sk, err = 0;

	sk = g_io_channel_unix_get_fd(chan);
	ctxt->io_id = 0;

	len = sizeof(err);
	if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
		err = errno;
		goto failed;
	}

	if (err != 0)
		goto failed;

	if (sdp_set_notify(ctxt->session, search_completed_cb, ctxt) < 0) {
		err = EIO;
		goto failed;
	}

	search = sdp_list_append(NULL, &ctxt->uuid);
	attrids = sdp_list_append(NULL, &range);
	if (sdp_service_search_attr_async(ctxt->session,
				search, SDP_ATTR_REQ_RANGE, attrids) < 0) {
		sdp_list_free(attrids, NULL);
		sdp_list_free(search, NULL);
		err = EIO;
		goto failed;
	}

	sdp_list_free(attrids, NULL);
	sdp_list_free(search, NULL);

	/* Set callback responsible for update the internal SDP transaction */
	ctxt->io_id = g_io_add_watch(chan,
				G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
				search_process_cb, ctxt);
	return FALSE;

failed:
	sdp_close(ctxt->session);
	ctxt->session = NULL;

	if (ctxt->cb)
		ctxt->cb(NULL, -err, ctxt->user_data);

	search_context_cleanup(ctxt);

	return FALSE;
}
开发者ID:Xperia-Nicki,项目名称:android_platform_sony_nicki,代码行数:56,代码来源:glib-helper.c

示例14: main

int main(int argc, char **argv)
{
    struct sockaddr_rc loc_addr = {0}, rem_addr = {0};
    char buff[1024] = {0};
    int s = 0, client = 0, bytes_read = 1;
    unsigned int opt = sizeof(rem_addr);
    sdp_session_t * session = register_service();
    int leftToRead = 0;
    
    /* creamos el socket */
    s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
    
    /* cargamos loc_addr para luego hacer el bind */
    loc_addr.rc_family = AF_BLUETOOTH;
    loc_addr.rc_bdaddr = *BDADDR_ANY;
    loc_addr.rc_channel = 11;
    
    /* hacemos el bind NOTE: error check falta*/
    if(bind(s, (struct sockaddr *)&loc_addr, sizeof(loc_addr)) < 0)
	    printf("Error al hacer el bind\n");
    else
	    printf("Hicimos el bind correctamente\n");
    /* listening con tamaño cola 1 */
    if (listen(s, 1) < 0)
	    printf("Error al hacer el listen\n");
    else
	    printf("Hicimos el listen correctamente\n");
    
    
    /* aceptamos conecciones */
    printf("Esperando clientes.... \n");
    client = accept(s, (struct sockaddr *)&rem_addr, &opt);
    ba2str(&rem_addr.rc_bdaddr,buff);
    printf("Aceptamos conexion de: %s\n", buff);
    memset(buff, 0, sizeof(buff));
    bytes_read = recv(client, buff, sizeof(buff), 0);
    leftToRead = (int)buff[0];
    printf("nos van a mandar %d bytes\n",leftToRead);
    while (leftToRead > 0) {
	memset(buff, 0, sizeof(buff));
	bytes_read = recv(client, buff, sizeof(buff), 0);
	leftToRead -= bytes_read;
	if (bytes_read > 0)
		printf("Recibimos %d\nDatos:%s\n", bytes_read, buff);
    }
    printf ("enviando...\n");
    send(client, "maraca", 6, 0);
	
    close(client);
    close(s);
    sdp_close(session);
    
    return 0;
    
}
开发者ID:aguperezpala,项目名称:linux-bluetooth-qt,代码行数:55,代码来源:rfcomm-server-sdp2.c

示例15: main

int main(int argc, char **argv){
	struct sockaddr_rc loc_addr = { 0 }, rem_addr = { 0 };
	char buf[1] = { 0 };
	int s, client, bytes_read;
	socklen_t opt = sizeof(rem_addr);
	sdp_session_t *sdp_session;

	//register the service an acquire the session
	sdp_session = register_service();
	
	for(;;){
		// allocate socket
		s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

		// bind socket to port 1 of the first available 
		// local bluetooth adapter
		loc_addr.rc_family = AF_BLUETOOTH;
		loc_addr.rc_bdaddr = *BDADDR_ANY;
		loc_addr.rc_channel = (uint8_t) SVC_CHANNEL;
	

		bind(s, (struct sockaddr *)&loc_addr, sizeof(loc_addr));

		// put socket into listening mode
		fprintf(stderr, "listening\n");
		listen(s, 1);

		// accept one connection
		fprintf(stderr, "accepting\n");
		client = accept(s, (struct sockaddr *)&rem_addr, &opt);

		ba2str( &rem_addr.rc_bdaddr, buf );
		fprintf(stderr, "accepted connection from %s\n", buf);
		memset(buf, 0, sizeof(buf));

		// read data from the client
	
		initInput();
		bytes_read = 1;
		while(bytes_read > 0){
			bytes_read = read(client, buf, sizeof(buf));
			scroll(buf[0]);
			printf("received %d\n", buf[0]);
		}	
		deinitInput();

		// close connection
		close(client);
		close(s);		
	}
	
	//close sdp session	
	sdp_close(sdp_session);
	return 0;
}
开发者ID:lanixXx,项目名称:scratch,代码行数:55,代码来源:btserver.c


注:本文中的sdp_close函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。