I need to develop an application from which devices can communicate from time to time (a device sends a simple message , The second one sends a response).
This communication is often not going to happen (once in several minutes), so it does not seem appropriate to have a permanent relationship between the devices. In addition, the connection may be lost for some reason, so I will need some sort of recovery logic.
Instead, I like the app to set up a new connection when it needs to send data to a colleague. However, the specs say that, after the Currently, I'm thinking of not shutting down the server socket and processing the incoming connections in a synchronous manner so that the app does not try to accept new connections until the last connection is processed and closed. . What will happen if another coworker tries to join the middle of this process? Will this fail or will the server block until it is ready to accept it? The documentation says, "BluetoothSourceSocket (and should be skipped), as long as you accept more connections Do not want to. "Since you want to accept more connections, you should keep it. Documentation also tells the following about the acceptable way of server server. Accepting is a blocked call. It will return when a connection was accepted or an exception happened. A connection is accepted when a remote device has sent a connection request with UUID that matches the one registered with this hearing server socket. If successful, () will return a connected BluetoothSocket. BluetoothServerSocket.accept , the server socket should be closed. This means that the app will no longer be able to get incoming connections.
No comments:
Post a Comment