Return-Path: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C4F803.A1078683" Message-ID: <0AAF93247C75E3408638B965DEE11A70026375D1@i2km41-ukdy.domain1.systemhost.net> From: To: Subject: [Bluez-users] Question re .bind() call on an RFCOMM socket Sender: bluez-users-admin@lists.sourceforge.net Errors-To: bluez-users-admin@lists.sourceforge.net Reply-To: bluez-users@lists.sourceforge.net List-Unsubscribe: , List-Id: BlueZ users List-Post: List-Help: List-Subscribe: , List-Archive: Date: Tue, 11 Jan 2005 17:33:14 -0000 This is a multi-part message in MIME format. ------_=_NextPart_001_01C4F803.A1078683 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi =20 =20 I am trying to understand how bind() call to BlueZ RFCOMM socket behaves . Code ... =20 SNIP... #include #include =20 int main () { =20 int sock ; bdaddr_t bdaddr ; struct sockaddr_rc loc_addr; =20 SNIP ... =20 /** Assume we have BT address of a local BT interface in bdaddr **/ =20 If ((sock =3D socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) { printf("Cannot create socket: %s (errno: %d)\n", strerror(errno)); } =20 =20 loc_addr.rc_family =3D AF_BLUETOOTH; bacpy( &(loc_addr.rc_baddr), bdaddr); =20 /* Channel allocation */=20 loc_addr.rc_channel =3D 1; =20 /*** OR loc_addr.rc_channel =3D 0; ??? <=3D What effect would this = have ??? ***/ =20 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 ; } =20 snip ... }=20 =20 =20 If the loc_addr.rc_channel were set to 0, does the bind() call automatically allocate an unused RFCOMM server channel ? =20 =20 Thanks =20 Graeme Brown =20 =20 =20 ------_=_NextPart_001_01C4F803.A1078683 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi

 

 

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

Code = …

 

SNIP…<= /span>

#include <bluetooth/bluetooth.h><= /p>

#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 =3D socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) {

     printf(“Cannot create socket: %s (errno: %d)\n”, strerror(errno));

}

 

 

loc_= addr.rc_family =3D AF_BLUETOOTH;

bacpy( &(loc_addr.rc_baddr), bdaddr);

 

/* Channel allocation = */

loc_= addr.rc_channel =3D 1;

 

/*** OR loc_addr.rc_channel =3D 0;  = ???   <=3D 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

 

 

 

=00 ------_=_NextPart_001_01C4F803.A1078683-- ------------------------------------------------------- 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 Bluez-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-users