Hi.
I am trying to write an application that gets the notification if some other bluetooth enabled device tries and connect.
The following is the segment of the code that I had written:

TInt result;
TNameEntry nentry;
THostName hostname;

// Start comm server if necessary
result = StartC32();
if (result != KErrNone && result != KErrAlreadyExists) User::Leave(result);

// Connect to the socket server
result = socksvr.Connect();
if (result != KErrNone) User::Leave(result);

// Load the protocol
result = socksvr.FindProtocol(_L("L2CAP"), protocolInfo);
User::LeaveIfError(result);

result = iListener.Open(socksvr, protocolInfo.iAddrFamily, protocolInfo.iSockType, protocolInfo.iProtocol);
if (result != KErrNone) User::Leave(result);

the problem that I am facing is that everytime I execute the line "iListener.Open", the value that is there is variable result is -21, and thus the program terminates.
I have no idea as to why this is happening. Can anyone of you help.
Thanks and regards.
Gautam Adlakha.