UtpSocketManager
Demultiplexes one UDP socket across many UtpStreams: the port of libtorrent's utp_socket_manager (src/utp_socket_manager.cpp) plus the session-level routing that shares the listen socket between uTP and the DHT.
libtorrent runs uTP, the DHT and UDP trackers over the same listen socket; session_impl::on_udp_packet sniffs each datagram and hands uTP-shaped ones (incoming_packet) to the manager, which routes by connection id, turning ST_SYNs with no matching stream into new incoming connections. This class does the same:
start pumps socket; a datagram is uTP iff its first byte decodes as
version == 1with a known packet type. A bencoded DHT message starts with'd'= 0x64, which fails that test. libtorrent discriminates the same way.uTP datagrams are routed to the UtpStream registered under
(host, port, connection-id); an unmatchedST_SYNbecomes a passive open: a new stream is created, fed the SYN, and handed to onIncomingConnection.everything else lands in the inbox behind dhtTransport, a virtual DatagramTransport the io.github.yuroyami.kitetorrent.session.dht.DhtNode consumes unchanged.
Connection-id arithmetic (see UtpStream): an active open with id I sends on I and receives on I-1; its SYN advertises I-1. The passive side derives send C/receive C+1 from the SYN's id C. Inbound routing therefore keys on the receiver's id: I-1 for streams we opened, C+1 for accepted ones.
Properties
Functions
A virtual DatagramTransport carrying every non-uTP datagram, for the DHT. close() is a no-op, because the manager owns the real socket.
Close stream and drop its routing entry.
Live stream count (for tests/observability).