Difference beetwen Bluez and Affix sockets

The Bluez and Affix use very similar programming socket interface. In the example below I will show how to adopt program design to work with Bluez to the Affix stack. The information about adoption remote control program you can find here.

/* Bluetooth address structures */
bdaddr_t bdaddr;
#ifdef AFFIX
BD_ADDR bdaddr;
#endif

/* Socket address structures */
#ifndef AFFIX
   struct sockaddr_rc      loc_addr;
#else
   struct sockaddr_affix   saddr;
#endif

/* Create socket */
#ifndef AFFIX
        if( (s = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0 )
#else
        if( (s = socket(PF_AFFIX, SOCK_STREAM, BTPROTO_RFCOMM)) < 0 )
#endif

/* Socket parameters */
#ifndef AFFIX
        loc_addr.rc_family = AF_BLUETOOTH;
        loc_addr.rc_bdaddr = bdaddr;
        loc_addr.rc_channel = uint8_t(channel);
#else
        saddr.family = AF_AFFIX;
        saddr.bda = bdaddr;
        saddr.port = channel;
#endif

/* Bind socket */
#ifndef AFFIX
        if( bind(s, (struct sockaddr *) &loc_addr, sizeof(loc_addr)) < 0 )
#else
        if( bind(s, (struct sockaddr *) &saddr, sizeof(saddr)) < 0 )
#endif

After creating socket we can use read and write calls. So the later development shouldn't differ.