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
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