Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

How extract client address on server ??

Help
andrea_cc
2006-10-11
2013-05-01
  • andrea_cc
    andrea_cc
    2006-10-11

    Hello,
    i ve a very simple question. I got a simple obex server code that runs fine.I ve taken the obexserver sample souce code as a tamplate. Question is: how/where can i get, on my server, the bt address of the client ??

    thanks a lot

     
    • TreNrod
      TreNrod
      2008-01-03

      I know that this Thread is quite old, but actuelly it was the first i found when i had the same problem... so.

      I cant remember the link where i found a short desc about it. But the version i used is...

      /**
      * Lese BD von Client aus
      */
      int get_bdaddr(obex_t *handle, char *str) {
              int     fd;
              struct  sockaddr_rc     client_saddr;
              socklen_t               len = sizeof(struct sockaddr_rc);

              fd = OBEX_GetFD(handle);
              if( fd < 0 ){
                      return 0;
              }

              if( getpeername(fd, (struct sockaddr *)&client_saddr, &len) ){
                      return 0;
              }

              ba2str(&client_saddr.rc_bdaddr,str);
      }

      As you usually will know, handle is the pointer from client and str stores the BD-Client address. And dont forget to include rfcomm ;).
      I tried this in the obexpushd0.5 after and it worked.