|The sequence should be something like:
To accept connections, the following steps are performed by the server side:
1. A socket is created with socket(2).
2. The socket is bound to a local address using bind(2), so that
other sockets may be connect(2)ed to it.
3. A willingness to accept incoming connections and a queue
limit for incoming connections are specified with listen().
4. Connections are accepted with accept(2).
as described at listen(2) - Linux manual page[^].
The client then connects by the following:
Creates the socket
Calls bind to bind the socket to the address of the server
starts sending messages
as described at bind(2) - Linux manual page[^].
I am not sure what special rules are needed when connecting via Bluetooth.