[J2ME] StreamConnectionNotifier.acceptAndOpen() cancellation

J

JScoobyCed

Hi,

I am using a StreamConnectionNotifier to open a server side of a
serial connection. I should say a 'master' side.
My code works fine and i can open the connection, send and receive data
to and from a client. But What I would like is to cancel the server
waiting by a 'acceptAndOpen()'.
<code>
1: StreamConnectionNotifier notifier = null;
2: StreamConnection sconn = null;
3: // Connection RFCOMM (serie sur BlueTooth)
4: String url = "btspp://localhost:"+uuid;
5: try {
6: // Cree le StreamConnectionNotifier
7: notifier = (StreamConnectionNotifier)Connector.open(url);
8: // Attend un client pour creer une connection
9: sconn = notifier.acceptAndOpen();
10: } catch(Exception exc) { //... }
</code>

When the master is waiting for a slave, it is blocked by the
'acceptAndOpen()' call. I triied
notifier.close(), but the MIDlet blocks and I have to switch-off the
phone, then switch it on. Not a great thing for a user. I also triied
notifier = null;
(yeah, I know... this is dangerous and unexpected behaviour may
happen... it's just for test)

I would appreciate any suggestion or help. Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top