views:

235

answers:

1

I'm connecting to a bluetooth socket like so,

SOCKET s = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); 

SOCKADDR_BTH bthSockAddr;
bthSockAddr.btAddr = addr;
bthSockAddr.addressFamily = AF_BTH;
bthSockAddr.port = BT_PORT_ANY;
bthSockAddr.serviceClassId = SerialPortServiceClass_UUID;

if ( 0==connect( sOut, (sockaddr*)&bthSockAddr,sizeof(bthSockAddr)) )
{
   printf( "connect success\n" );

   T data;
   int size = sizeof(T);
   int optname = ... ;
   if ( 0!=getsockopt( s, 0, optname, (char*)&data, &size ) )
   {
      //  getsockopt failed
   }
}

The connections succeeds, but getsockopt seems to fail for all optname/T pairs that I try (e.g. optname==SO_DEBUG, T==BOOL ). Does getsockopt just make no sense in this context? Have tried each of,

SO_ACCEPTCONN, SO_BROADCAST, SO_CONDITIONAL_ACCEPT,
SO_DEBUG, SO_DONTLINGER, SO_DONTROUTE, SO_EXCLUSIVEADDRUSE,
SO_KEEPALIVE, SO_OOBINLINE, SO_REUSEADDR, SO_ERROR, 
SO_GROUP_PRIORITY,  SO_RCVBUF, SO_SNDBUF, SO_TYPE, SO_MAX_MSG_SIZE

with their appropriate types. I'm aware not all option always apply, but can't find a list of what does apply for my socket type.

Context -- I'm trying to write a platform independent API for a bluetooth connection and want to dump debug info for the socket.

A: 

Never mind, found all my answers here?

why don't you post a detailed answer as opposed to posting a link? Your answer will persist and be of you to many, while the link might not have this life span and addresses a general problem. Thanks
vehomzzz