Connecting and Transferring Data to a Remote Device

Once the device and service have been established, you can connect to the remote service and start using it.

How to Communicate with a Remote Device

Connect to the device through the Connect() function of the generic Symbian platform socket interface [[[ERROR: [NOKX000E] Unable to find definition for key reference 'RSocket']]]RSocket. Bluetooth sockets can be opened using the L2CAP and RFCOMM protocols. For an L2CAP Bluetooth socket, the "port" is the Protocol/Service Multiplexer (PSM) to which to connect; for an RFCOMM the port is the server channel. Where these values are not known, they can be read from the service attribute ProtocolDescriptorList. See Using Bluetooth Service Discovery Agent for details.

You can read and write data using the socket in whatever format the target service expects (AT commands, text, HTTP, PPP etc).


// Assume have a TInquirySockAddr object, addr, with relevant device info

// Connect an L2CAP socket
RSocket socket;
// although CBluetoothSocket may be a better option.
RSocketServ socketServ;
TRequestStatus status;

if (status == KErrNone)
    // Write some simple data

// Close socket


  • For both the RFCOMM and L2CAP protocols, no data can be sent or received in the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'RSocket']]]Connect() and [[[ERROR: [NOKX000E] Unable to find definition for key reference 'RSocket']]]Shutdown() calls. The versions of these calls that take extra data panic.

  • RFCOMM uses sockets of the stream socket ([[[ERROR: [NOKX000E] Unable to find definition for key reference 'RSocket']]]KSockStream) type.

  • L2CAP uses sockets of the sequenced packet ([[[ERROR: [NOKX000E] Unable to find definition for key reference 'RSocket']]]KSockSeqPacket) type.

Where Next?

This tutorial set takes you through all the steps involved in setting up and communicating over a Bluetooth connection.