I'm trying to setup a bluetooth connection between two phones by running a service from one phone and then connecting to it from the other (for purposes of bluetooth gaming)

Here are the steps taken:

- Server boots and asks if it can use bluetooth connectivity (confirm)

- Server sets up a connection on url: "btspp://localhost:A25665EE9F9146109085C2055C888B39;authenticate=true;authorize=true;encrypt=true;name=BT-Test"

- Client does a device discovery, which succesfully recognizes the device running the service during service discovery.

- Client asks to use connectivity (confirm)

- Server recieves connection request and notifies with a "allow to connect" message (confirm)

- Server creates a client connection handler for the new device and starts it

- Client attempts to send data and gets an error: Symbian OS Error -11 (kErrAlreadyExists)

The error is returned from the following code:

connectionNotifier =
(StreamConnectionNotifier) Connector.open(url);
This is the same code used by the server to setup its connection service, so I'm wondering what the error means and where I went wrong. Perhaps the client and server share the same connection service? or my url is wrong?

The url used in that call is retrieved in the following manner:

String conURL = gameService.getConnectionURL(
ServiceRecord.AUTHENTICATE_ENCRYPT, false);
Some more code snippets:


Connection being setup...
public void setupConnection()
{
String property =
LocalDevice.getProperty("bluetooth.sd.trans.max");
sdTransMax = 8; //Integer.parseInt(property);

// set inquiry access mode for ConnectionService
if (!isServer)
{
try
{
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
}
catch(BluetoothStateException e)
{
String msg = e.getMessage();
Game.setString(msg);
}
}

if (!isServer)
{
try
{
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
}
catch (BluetoothStateException e)
{

}
// start application in client role
serverUseAuthentication = false;
serverUseEncryption = false;
synchronized (block_s)
{
try
{
myListener = new DiscListener();
}
catch (BluetoothStateException e)
{
//not much we can do...
}
}
Game.setString("Searching for Devices");

}
else
{
Game.setString("Starting Service...");
// start application in server role
try
{
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
}
catch (BluetoothStateException e)
{
Game.setString("Could not setDiscoverable!");
}
String url = SERVICE_URL;
url += ";authenticate=true";
url += ";authorize=true";
url += ";encrypt=true";
url += ";name=BT-Test";
m_connectionService = null;
m_connectionService = new ConnectionService(url, this);
}

}
Client attempting connect (where the crash occurs)
public void connect() {
try
{
Game.setString("Opening Connection");
streamConnection = (StreamConnection)Connector.open(serverConnectionString);
Game.setString("Setting up connection service.");
m_connectionService = null;
m_connectionService = new ConnectionService(serverConnectionString, ((Lingo)FalconApp.sharedInstance));
Game.setString("Creating clientHandler.");
clientHandler = new ClientConnectionHandler(m_connectionService, streamConnection, ((Lingo)FalconApp.sharedInstance));
}
catch (Exception e)
{
//crap
}
}