Return-Path: From: "Aveek Audhya" To: "'BlueZ development'" Date: Fri, 1 Jun 2007 19:18:02 +0530 MIME-Version: 1.0 In-Reply-To: <1180624077.3030.184.camel@cookie.hadess.net> Message-ID: Cc: bluez-users@lists.sourceforge.net Subject: Re: [Bluez-devel] connect fail : Operation now in progress Reply-To: BlueZ development List-Id: BlueZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0213695949==" Sender: bluez-devel-bounces@lists.sourceforge.net Errors-To: bluez-devel-bounces@lists.sourceforge.net This is a multi-part message in MIME format. --===============0213695949== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0000_01C7A481.956BE0C0" This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C7A481.956BE0C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Nocera, Thanks for your reply. What I have seen is that my socket's fd is by default blocking, every time it returns -1 after waiting for sometime. If I set it as non-blocking then it returns -1 immediately. I have set up a watcher with select() and getsockopt() call. It's like that .... s = socket(AF_BLUETOOTH, SOCK_STREAM/*SOCK_SEQPACKET*/, BTPROTO_RFCOMM); remote_addr.rc_family = AF_BLUETOOTH; // specifies the addressing family of the socket remote_addr.rc_channel = (uint8_t)4; // port no to connect to str2ba(dest, &remote_addr.rc_bdaddr); // address to connect to status = connect(s, (struct sockaddr*)&remote_addr, sizeof(struct sockaddr_rc)); if(status < 0) { if(errno == EINPROGRESS) { printf("EINPROGRESS : %s\n",strerror(errno)); do { timeout.tv_sec = 25; timeout.tv_usec = 0; FD_ZERO(&wr); FD_ZERO(&rd); FD_ZERO(&exceptfds); FD_SET(s,&wr); FD_SET(s,&rd); FD_SET(s,&exceptfds); if((status = select(s+1,&rd,&wr,&exceptfds,&timeout)) >0 ) { //struct protoent *result; len = sizeof(int); //while((result = getprotoent()) != NULL) //printf("name = %s, protocol = %d\n",result->p_name,result->p_proto); if(getsockopt(s,SOL_RFCOMM,SO_ERROR,(void*)&valopt,&len) < 0) { printf("Error in getsockopt() %d - %s\n",errno,strerror(errno)); _exit(0); } if(valopt) // check the value returned { printf("Error in delayed connection() %d - %s\n",valopt,strerror(valopt)); _exit(0); } printf("before break\n"); break; } else if(status < 0 && errno != EINTR) { printf("Error connecting %d - %s\n",errno, strerror(errno)); _exit(0); } else { printf("errno = %d\n",errno); perror("Timeout in select(). exiting... "); _exit(0); } }while(1); /**/ } else { printf("errno = %d\n",errno); perror("Error in connect. exiting... "); _exit(0); } } But for SOL_RFCOMM in getsockopt() I get an error message at run time .. Error in getsockopt() 92 - Protocol not available ..... although SOL_RFCOMM is defined in '/usr/include/Bluetooth/bluetooth.h'. Is it the right way to implement a watcher on a socket fd ? One thing I forgot to mention that after making connect() call, my mobile phone ask for 'accept connection request', and after pressing 'yes' connect() returns -1 with error value 'Operation now in progress'. Unfortunately I couldn't find 'manager.c' in 'bluez-utils-3.9/serial/'. The folder doesn't contain any .c file except Makefile, Makefile.am and Makefile.in. 'manager.c' is present only in 'bluez-utils-3.9/daemon' folder, but there is no 'rfcomm_connect()' implementation. Probably we are using different utils version. Thanks again for your time. -----Original Message----- From: Bastien Nocera [mailto:hadess@hadess.net] Sent: Thursday, May 31, 2007 8:38 PM To: BlueZ development Cc: bluez-users@lists.sourceforge.net Subject: Re: [Bluez-devel] connect fail : Operation now in progress On Thu, 2007-05-31 at 16:44 +0530, Aveek Audhya wrote: > Hi, > > I am trying to communicate with a J2ME application running > on my mobile phone(Nokia 6600) using a client program running on a > Linux machine (FC6). The 'sdptool browse' reports that the J2ME > application is listening on channel 4. The J2ME application is using > btspp protocol whereas my client side application is using RFCOMM. But > when I run the client application, the 'connect' system-call fails > (returns -1) with error value "Operation now in progress". I am using > BlueZ protocol stack. > > What can be the probable reason for this kind of behavior? Any > suggestion is appreciated. You probably made the socket's fd non-blocking. Either make it blocking, or setup a watcher on the fd to wait for the link to be created. See rfcomm_connect() in bluez-utils/serial/manager.c -- Bastien Nocera ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ------=_NextPart_000_0000_01C7A481.956BE0C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Nocera,

      = Thanks for your reply. What I have seen is that my socket's fd is by default blocking, every time it = returns -1 after waiting for sometime. If I set it as non-blocking then it returns = -1 immediately.  

      = I have set up a watcher with select() and getsockopt() call.

It's like that = ....

 

s =3D socket(AF_BLUETOOTH, SOCK_STREAM/*SOCK_SEQPACKET*/, = BTPROTO_RFCOMM);

 

=

remote_addr.rc_family= =3D AF_BLUETOOTH; // specifies = the addressing family of the socket

remote_addr.rc_channel =3D (uint8_t)4; // port no to connect to

str2ba(dest, &remote_addr.rc_bdaddr); // address to connect to

 

=

status =3D connect(s, (struct sockaddr*)&remote_addr, sizeof(struct = sockaddr_rc));

 

=

if(status < = 0)

      = {

        = ;    if(errno =3D=3D = EINPROGRESS)

        = ;    {

        = ;          printf("EINPROGRESS : %s\n",strerror(errno));

        = ;          do

        = ;          = {

        = ;            =     timeout.tv_sec =3D = 25;

        = ;            =     timeout.tv_usec =3D = 0;

        = ;            =     FD_ZERO(&wr);

        = ;            =     FD_ZERO(&rd);     =

        = ;            =     FD_ZERO(&exceptfds);

 

=

        = ;            =     FD_SET(s,&wr);

        = ;            =     FD_SET(s,&rd);

        = ;            =     FD_SET(s,&exceptfds);

 

=

        = ;            =     if((status =3D select(s+1,&rd,&wr,&exceptfds,&timeout)) >0 = )

        = ;            =     {

        = ;            =           //struct protoent = *result;

        = ;            =           len =3D sizeof(int);

        = ;            =           //while((result =3D getprotoent()) !=3D NULL)

        = ;            =           //printf("name =3D %s, protocol =3D %d\n",result->p_name,result->p_proto);

 

=

        = ;            =           =

        = ;          if(getsockopt(s,SOL_RFCOMM,SO_ERROR,(void*)&valopt,&len) < = 0)

        = ;            =           = {

        = ;            =             &= nbsp;   printf("Error in getsockopt() %d - %s\n",errno,strerror(errno));

        = ;            =             &= nbsp;   _exit(0);

        = ;            =           = }

        = ;            =    

        = ;            =           if(valopt) // check the = value returned

        = ;            =           {     =

        = ;            =             &= nbsp;   printf("Error in delayed connection() %d - %s\n",valopt,strerror(valopt));

        = ;            =             &= nbsp;   _exit(0);

        = ;            =           = }

        = ;            =           printf("before break\n");

        = ;            =           break;

        = ;            =     }

        = ;            =     else if(status < 0 && errno !=3D EINTR)

        = ;            =     {

        = ;            =           printf("Error connecting %d - %s\n",errno, strerror(errno));

        = ;            =           _exit(0);

        = ;            =     }

        = ;            =     else

        = ;            =     {

        = ;            =           printf("errno =3D %d\n",errno);

        = ;            =           perror("Timeout in select(). exiting... = ");

        = ;            =           _exit(0);

        = ;            =     }

        = ;          }while(1); /**/

        = ;    }

        = ;    else

        = ;    {

        = ;          printf("errno =3D %d\n",errno);

        = ;          perror("Error in connect. exiting... = ");

        = ;          _exit(0);

        = ;    }

      = }

 

But for SOL_RFCOMM = in getsockopt() I get an error message at run time ……  Error in getsockopt() 92 = – Protocol not available …………… although = SOL_RFCOMM is = defined in ‘/usr/include/Bluetooth/bluetooth.h’. Is it = the right way to implement a watcher on a socket fd ?

 

One thing I forgot to mention that after making connect() call, my mobile phone ask for ‘accept connection request’, = and after pressing ‘yes’ connect() returns -1 with error value = ‘Operation now in progress’.    

 

Unfortunately I couldn’t find ‘manager.c’ in ‘bluez-utils-3.9/serial/’. The folder doesn’t = contain any .c file except Makefile, Makefile.am and Makefile.in. ‘manager.c’ is present only in ‘bluez-utils-3.9/daemon’ folder, but = there is no ‘rfcomm_connect()’ implementation. Probably we are using = different utils version.

Thanks again for your time.

 

 

-----Original Message-----
From: Bastien Nocera [mailto:hadess@hadess.net]
Sent
: Thursday, May 31, 2007 8:38 PM
To: BlueZ development
Cc: bluez-users@lists.sourceforge.net
Subject: Re: [Bluez-devel] connect fail : = Operation now in progress

 

On Thu, 2007-05-31 at 16:44 +0530, Aveek Audhya = wrote:

> Hi,

>

>       &nbs= p;     I am trying to communicate with a J2ME application = running

> on my mobile phone(Nokia 6600) using a client program = running on a

> Linux machine (FC6). The ‘sdptool browse’ = reports that the J2ME

> application is listening on channel 4. The J2ME application = is using

> btspp protocol whereas my client side application is using = RFCOMM. But

> when I run the client application, the = ‘connect’ system-call fails

> (returns -1) with error value “Operation now in progress”. I am using

> BlueZ protocol stack.

>

> What can be the probable reason for this kind of behavior? = Any

> suggestion is appreciated.

 

You probably made the socket's fd non-blocking. Either make it blocking,

or setup a watcher on the fd to wait for the link to be = created.

 

See rfcomm_connect() in = bluez-utils/serial/manager.c

 

--

Bastien Nocera <hadess@hadess.net> =

 

 

-----------------------------------------------------------------= --------

This SF.net email is sponsored by DB2 = Express

Download DB2 Express C - the FREE version of DB2 express and = take

control of your XML. No limits. Just data. Click to get it = now.

http://sourceforge.net/powerbar/db2/

=

_______________________________________________=

Bluez-devel mailing list

Bluez-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/bluez-devel

------=_NextPart_000_0000_01C7A481.956BE0C0-- --===============0213695949== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ --===============0213695949== 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 --===============0213695949==--