4

Environment: Ubuntu 14.04 running in vmplayer.

in PyBluez Example, rfcomm-server.py, Problem with running RFCOMM server on PORT_ANY

code chunk:

from bluetooth import *

erver_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)

I always get _bluetooth.error: (98, 'Address already in use') in the bind operation.

This thread shows to disable pnat and it works. my questions are

  1. In this case, how do I know which service is using the RFCOMM channel? is there command to list them?

    sdptool browse local

doesn't show that channel 1 is in use.

  1. after disabling pnat in /etc/bluetooth/main.config, channel 1 seems released and I can run rfcomm-server.py without problem. However, even if I roll back by comment out the line "DisablePlugins = pnat" and restart bluetooth service again, channel 1 of RFCOMM is not occupied anymore!
1
  • 1
    The currently used channels can be read from /sys/kernel/debug/bluetooth/rfcomm. The currently active RFCOMM sockets can be read from /proc/net/rfcomm. Unfortunately I cannot find any way to relate these entries, i.e. to get the channel used by a specific RFCOMM socket. The socket inode can be mapped to a process ID by searching for it in /proc/*/fd/*. It seems the kernel does not currently offer a netlink sock diag interface that could be used to gather this information. Sep 27, 2020 at 17:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.