createSocket method
UDPSocket
createSocket(
- UDX udx,
- String host,
- int port, {
- ConnectionId? localCid,
- ConnectionId? remoteCid,
- bool isServer = false,
Creates or retrieves a UDPSocket for a given peer.
For dialing: a second call for the same host:port returns the first
socket. Inbound connections don't go through this; each one gets its own
socket, keyed by its connection ID.
Implementation
UDPSocket createSocket(
UDX udx,
String host,
int port, {
ConnectionId? localCid,
ConnectionId? remoteCid,
bool isServer = false,
}) {
final peerKey = '$host:$port';
final existing = socketsByPeer[peerKey];
if (existing != null) return existing;
return _newSocket(udx, host, port, localCid: localCid, remoteCid: remoteCid, isServer: isServer);
}