All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aveek Audhya" <aveek@rebaca.com>
To: "'BlueZ development'" <bluez-devel@lists.sourceforge.net>
Cc: bluez-users@lists.sourceforge.net
Subject: Re: [Bluez-devel] connect fail : Operation now in progress
Date: Fri, 1 Jun 2007 19:18:02 +0530	[thread overview]
Message-ID: <E1Hu7Ub-0003BE-La@mail.sourceforge.net> (raw)
In-Reply-To: <1180624077.3030.184.camel@cookie.hadess.net>


[-- Attachment #1.1: Type: text/plain, Size: 5537 bytes --]

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 <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

[-- Attachment #1.2: Type: text/html, Size: 37564 bytes --]

[-- Attachment #2: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
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/

[-- Attachment #3: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

  reply	other threads:[~2007-06-01 13:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-31 11:14 [Bluez-users] connect fail : Operation now in progress Aveek Audhya
2007-05-31 15:07 ` [Bluez-devel] " Bastien Nocera
2007-06-01 13:48   ` Aveek Audhya [this message]
2007-06-01 13:56     ` Bastien Nocera
2007-06-06 13:16       ` Aveek Adhya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1Hu7Ub-0003BE-La@mail.sourceforge.net \
    --to=aveek@rebaca.com \
    --cc=bluez-devel@lists.sourceforge.net \
    --cc=bluez-users@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.