03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

user interaction, as well as for disabling additional security features including data<br />

encryption.<br />

As we can see in CGdpBTReceiver::OpenL(), we follow a standard approach in setting<br />

up our socket to listen for a connection:<br />

void CGdpBTReceiver::OpenL(MGdpPacketHandler& aHandler)<br />

{<br />

DEBUG_PRINT(_L("Entering CGdpBTReceiver::OpenL"));<br />

// Make sure the current iHandler is NULL - if it isn't then<br />

// we've already got a handler so Panic<br />

__ASSERT_DEBUG(iHandler == NULL, GdpUtil::Panic<br />

(GdpUtil::EReceiverInUse));<br />

iHandler = &aHandler;<br />

// Get the descriptor for protocol we are using. Better be<br />

Bluetooth...<br />

TProtocolDesc& desc = iResMan.ProtocolDesc();<br />

// Open the Listen Socket<br />

User::LeaveIfError(iListenSocket.Open(iResMan.SocketServer(),<br />

desc.iAddrFamily,<br />

desc.iSockType,<br />

desc.iProtocol));<br />

// Set up the port to listen on<br />

TInt port = 0x0b; // Port 11 for GDP<br />

iAddr.SetPort(port);<br />

// Now set the socket to listen on the right port<br />

TInt ret = iListenSocket.Bind(iAddr);<br />

// If the Bind() didn't succeed we're outta here!<br />

if (ret != KErrNone)<br />

User::Leave(KErrInUse); // Port is in use<br />

// Listen with a queue size of 4 (random) to allow more than<br />

// one connection

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!