2005-01-11 17:33:14

by graeme.n.brown

[permalink] [raw]
Subject: [Bluez-users] Question re .bind() call on an RFCOMM socket

Hi


I am trying to understand how bind() call to BlueZ RFCOMM socket
behaves .
Code ...

SNIP...
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>

int main ()
{

int sock ;
bdaddr_t bdaddr ;
struct sockaddr_rc loc_addr;

SNIP ...

/** Assume we have BT address of a local BT interface in bdaddr **/

If ((sock = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) {
printf("Cannot create socket: %s (errno: %d)\n", strerror(errno));
}


loc_addr.rc_family = AF_BLUETOOTH;
bacpy( &(loc_addr.rc_baddr), bdaddr);

/* Channel allocation */
loc_addr.rc_channel = 1;

/*** OR loc_addr.rc_channel = 0; ??? <= What effect would this have
??? ***/

if ( bind(sock, (struct sockaddr *) &loc_addr, sizeof(loc_addr)) < 0 ) {
printf("Cannot bind to socket: %s (errno: %d)\n", strerror(errno));
close(sock);
exit -1 ;
}

snip ...
}


If the loc_addr.rc_channel were set to 0, does the bind() call
automatically allocate an unused RFCOMM server channel ?


Thanks

Graeme Brown




2005-01-11 18:56:34

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-users] Question re .bind() call on an RFCOMM socket

Hi Graeme,

> I am trying to understand how bind() call to BlueZ RFCOMM socket
> behaves .
>
> If the loc_addr.rc_channel were set to 0, does the bind() call
> automatically allocate an unused RFCOMM server channel ?

if you use the latest kernel then it will select the next unused RFCOMM
channel.

Regards

Marcel




-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users