I run multiple bonjour client using pidgin, A, B, and C.
when B and C talk to A , I find A uses the same port (with wireshark I can see the packets) for MDNS and communication,
but B and C, each has two different ports one for MDNS ,one for socket connection.
how does A work, why it can work with only one port? how can one port provides multiple connections?
Attention: if it is multithread ,then when it accepts a connection it will create a new socket with another free port, but I saw the packets from wireshark, client A did just use the same port for communication and MDNS.
A TCP connection is actually identified by the tuple: (source_address, source_port, destination_address, destination_port). So as long as one of these is different there is no problem.
In practice, what you say happens when a program listens for connections in a given port: any new connection is created with the same server port (but different client port or address).
For exmample, in my Linux machine, where I have a web server listening at port 80:
$ telnet localhost 80 &
$ telnet localhost 80 &
$ lsof -n -i TCP
...
TCP 127.0.0.1:45601->127.0.0.1:80
TCP 127.0.0.1:45602->127.0.0.1:80