yaniv hanya Active Member Licensed User Mar 26, 2020 #1 When I was playing with the FileTransfer tutorial , I got the following exception: "java.net.BindException: Address already in use" (It happened because I ran two services that listened to the same port) And I wondered, because the port we use is written in code, can't another application already use it? And if so, is there anything to do programmatically. And how can one check if the port is free before trying to connect to it?
When I was playing with the FileTransfer tutorial , I got the following exception: "java.net.BindException: Address already in use" (It happened because I ran two services that listened to the same port) And I wondered, because the port we use is written in code, can't another application already use it? And if so, is there anything to do programmatically. And how can one check if the port is free before trying to connect to it?
Erel B4X founder Staff member Licensed User Longtime User Mar 27, 2020 #2 yaniv hanya said: When I was playing with the FileTransfer tutorial Click to expand... Why? This is an old tutorial which points you to a newer, simpler and more powerful solution. yaniv hanya said: And I wondered, because the port we use is written in code, can't another application already use it? Click to expand... It can happen. Not very likely if you choose a random port as there aren't many things running in Android. You can catch this error and switch to a different port. The problem is that the other app that connects to this one will also need to switch to a different port. Another option is to use auto discovery: https://www.b4x.com/android/forum/threads/mqtt-chat-with-auto-discovery.75713/#content However it can also fail in some cases based on the network configuration. Upvote 0
yaniv hanya said: When I was playing with the FileTransfer tutorial Click to expand... Why? This is an old tutorial which points you to a newer, simpler and more powerful solution. yaniv hanya said: And I wondered, because the port we use is written in code, can't another application already use it? Click to expand... It can happen. Not very likely if you choose a random port as there aren't many things running in Android. You can catch this error and switch to a different port. The problem is that the other app that connects to this one will also need to switch to a different port. Another option is to use auto discovery: https://www.b4x.com/android/forum/threads/mqtt-chat-with-auto-discovery.75713/#content However it can also fail in some cases based on the network configuration.
yaniv hanya Active Member Licensed User Mar 29, 2020 #3 Erel said: Why? This is an old tutorial which points you to a newer, simpler and more powerful solution. Click to expand... It was convenient for me to use it because it shows the way of connecting, both Wifi and BT in one place, and I need both Upvote 0
Erel said: Why? This is an old tutorial which points you to a newer, simpler and more powerful solution. Click to expand... It was convenient for me to use it because it shows the way of connecting, both Wifi and BT in one place, and I need both