Return-Path: Message-ID: <001001c6ff87$c1d41f50$0100a8c0@kayleigh> From: "Olivier Le Pogam" To: "BlueZ development" Date: Fri, 3 Nov 2006 21:36:27 +0100 Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=======AVGMAIL-454BA8545789=======" Subject: [Bluez-devel] To blueZ developers : can't do two "connect" concurrently, help required ! Reply-To: Olivier Le Pogam , BlueZ development List-Id: BlueZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: bluez-devel-bounces@lists.sourceforge.net Errors-To: bluez-devel-bounces@lists.sourceforge.net --=======AVGMAIL-454BA8545789======= Content-Type: multipart/alternative; boundary="----=_NextPart_000_000D_01C6FF90.1E236F10" ------=_NextPart_000_000D_01C6FF90.1E236F10 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi, For the ones who have read my messages a few days ago ... I am still performing concurrency tests ! I run a server on 2 remote devices (one on channel 24, the other on channel 25), and I try to connect to them concurrently=20 from the same Linux box / BT key (the remote servers are simple "echo"=20 ones, the linux client is sending numbers from 1 to 10 with a sleep(1) = at=20 each step). I have a simple batch : client.sh : ./client 00:16:4E:83:2D:19 25 & ./client 00:0D:88:9B:FF:D7 24 & where client is called with BDADDR and channel Here is what I get in my logs : Connection to remote 00:16:4E:83:2D:19 channel 25 Connection to remote 00:0D:88:9B:FF:D7 channel 24 [00:16:4E:83:2D:19] Can't connect(111) =3D=3D=3D=3D> 111 is = connection refused [00:0D:88:9B:FF:D7] Connected to remote 00:0D:88:9B:FF:D7 channel 24, = from local 00:11:67:0D:2E:2C channel 24 [00:0D:88:9B:FF:D7] Sent 0 received 0 ... If I swap the order of calling "client" i.e : client.sh : ./client 00:0D:88:9B:FF:D7 24 & ./client 00:16:4E:83:2D:19 25 & Then it's still the first which can't connect (now it will be = 00:0D:88:9B:FF:D7) So basically, it seems that there can't be two "connect" concurrently on the same adaptor. Can please BlueZ developers confirm ? Thanks a lot Oli For who is interested, here is the interesting part of client.c : int main(int argc, char **argv) { struct sockaddr_rc laddr, raddr; int sk, i; memset(&laddr, 0, sizeof(laddr)); memset(&raddr, 0, sizeof(raddr)); laddr.rc_family =3D AF_BLUETOOTH; bacpy(&laddr.rc_bdaddr, BDADDR_ANY); laddr.rc_channel =3D 0; raddr.rc_family =3D AF_BLUETOOTH; str2ba(argv[1], &raddr.rc_bdaddr); raddr.rc_channel =3D atoi(argv[2]); =20 if (argc !=3D 3) { fprintf(stderr,"Usage: client address channel\n"); exit(EXIT_FAILURE); } debugOutput("Connection to remote %s channel %s", argv[1], argv[2]); sk =3D socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); if (sk < 0) { =20 debugOutput("[%s] Can't create RFCOMM socket", argv[1]); return -1; } if (bind(sk, (struct sockaddr *)&laddr, sizeof(laddr)) < 0) { debugOutput("[%s] Can't bind RFCOMM socket", argv[1]); close(sk); return -1; } if (connect(sk, (struct sockaddr *)&raddr, sizeof(raddr)) < 0) { debugOutput("[%s] Can't connect(%d)", argv[1], errno); close(sk); return -1; } char loc_addr[30]; strcpy(loc_addr, ""); =20 int len =3D sizeof(laddr);=20 if (getsockname (sk, &laddr, &len ) > 0) debugOutput("[%s] Can't getsockname", argv[1]); else ba2str(&laddr.rc_bdaddr, loc_addr); =20 debugOutput("[%s] Connected to remote %s channel %s, from local %s = channel %d", argv[1], argv[1], argv[2], loc_addr, laddr.rc_channel); =20 for (i =3D 0; i<10; i++) { char buf[1024]; sprintf(buf, "%d%c", i, 10); write(sk, buf, strlen(buf)); strcpy(buf, ""); =20 readString(sk, buf); if( strlen(buf) > 0 ) { debugOutput("[%s] Sent %d received %s", argv[1], i, buf); } else { debugOutput("[%s] Sent %d received no answer", argv[1], i); break; } sleep(1); } =20 close(sk); debugOutput("[%s] Disconnected", argv[1]); return 0; } ------=_NextPart_000_000D_01C6FF90.1E236F10 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi,
 
For the ones who have read my messages = a few days=20 ago ...
I am still performing concurrency tests = !
 
I run a server on 2 remote devices (one = on channel=20 24, the
other on channel 25), and I try to = connect to=20 them concurrently
from the same Linux box / BT key = (the remote=20 servers are simple "echo" =
ones, the linux client is sending = numbers=20 from 1 to 10 with a sleep(1) at =
each step).
 
I have a simple batch :
 
client.sh=20 :
./client 00:16:4E:83:2D:19  25 &
./client 00:0D:88:9B:FF:D7  = 24=20 &
 
where client is called with BDADDR and=20 channel
 
Here is what I get in my logs = :
 
Connection to remote 00:16:4E:83:2D:19 = channel=20 25
Connection to remote 00:0D:88:9B:FF:D7 channel = 24
[00:16:4E:83:2D:19]=20 Can't connect(111)    =3D=3D=3D=3D> 111 is connection=20 refused
[00:0D:88:9B:FF:D7] Connected to remote 00:0D:88:9B:FF:D7 = channel 24,=20 from local 00:11:67:0D:2E:2C channel 24
[00:0D:88:9B:FF:D7] Sent 0 = received=20 0
...
 
If I swap the order of calling "client" = i.e=20 :
 
client.sh :
./client 00:0D:88:9B:FF:D7  = 24=20 &
./client 00:16:4E:83:2D:19  25 = &
 
Then it's still the first which can't connect (now it will be=20 00:0D:88:9B:FF:D7)
 
So basically, it seems that there can't be=20 two "connect"
concurrently on the same adaptor.
 
Can please BlueZ developers confirm ?
 
Thanks a lot
Oli
 
For who is interested, here is the interesting part of client.c = :
 
int main(int argc, char **argv)
{
    struct=20 sockaddr_rc laddr, raddr;
    int sk, i;
 
    memset(&laddr, 0,=20 sizeof(laddr));
    memset(&raddr, 0,=20 sizeof(raddr));
 
    laddr.rc_family =3D = AF_BLUETOOTH;
   =20 bacpy(&laddr.rc_bdaddr, BDADDR_ANY);
    = laddr.rc_channel=20 =3D 0;
 
    raddr.rc_family =3D = AF_BLUETOOTH;
   =20 str2ba(argv[1], &raddr.rc_bdaddr);
    = raddr.rc_channel =3D=20 atoi(argv[2]);
 
   if (argc !=3D 3) = {
   =20  fprintf(stderr,"Usage: client address = channel\n");
   =20  exit(EXIT_FAILURE);
   }
 
 debugOutput("Connection to remote %s channel %s", argv[1],=20 argv[2]);
 
    sk =3D socket(AF_BLUETOOTH, SOCK_STREAM,=20 BTPROTO_RFCOMM);
    if (sk < 0)=20 {      =20
        debugOutput("[%s] Can't = create=20 RFCOMM socket", argv[1]);
        = return=20 -1;
    }
 
    if (bind(sk, (struct sockaddr *)&laddr,=20 sizeof(laddr)) < 0) {
       =20 debugOutput("[%s] Can't bind RFCOMM socket",=20 argv[1]);
       =20 close(sk);
        return=20 -1;
    }
 
    if (connect(sk, (struct sockaddr *)&raddr,=20 sizeof(raddr)) < 0) {
       =20 debugOutput("[%s] Can't connect(%d)", argv[1],=20 errno);
       =20 close(sk);
        return=20 -1;
    }
 
 char loc_addr[30];
 strcpy(loc_addr,=20 "");
 
    int len =3D sizeof(laddr);=20
    if (getsockname (sk, &laddr, &len ) >=20 0)
       debugOutput("[%s] Can't = getsockname",=20 argv[1]);
 else ba2str(&laddr.rc_bdaddr,=20 loc_addr);
  
 debugOutput("[%s] Connected to = remote %s=20 channel %s, from local %s channel %d", argv[1], argv[1], argv[2], = loc_addr,=20 laddr.rc_channel);
 
 for (i =3D 0; i<10;=20 i++)
 {
  char = buf[1024];
  sprintf(buf,=20 "%d%c", i, 10);
  write(sk, buf,=20 strlen(buf));
  strcpy(buf,=20 "");
  
  readString(sk, = buf);
  if(=20 strlen(buf) > 0 ) {
   debugOutput("[%s] Sent %d = received=20 %s", argv[1], i, buf);
    } else=20 {
   debugOutput("[%s] Sent %d received no answer", = argv[1],=20 i);
   break;
  }
  sleep(1);=
 }
 
   =20 close(sk);
 debugOutput("[%s] Disconnected", argv[1]);
 
    return = 0;
}
------=_NextPart_000_000D_01C6FF90.1E236F10-- --=======AVGMAIL-454BA8545789======= Content-Type: text/plain; x-avg=cert; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-Description: "AVG certification" No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.13.25/515 - Release Date: 03/11/2006 = --=======AVGMAIL-454BA8545789======= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 --=======AVGMAIL-454BA8545789======= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel --=======AVGMAIL-454BA8545789=======--