MCPcopy Create free account
hub / github.com/apple/foundationdb / createUDPSocket

Method createUDPSocket

fdbrpc/sim2.actor.cpp:2483–2499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2481};
2482
2483Future<Reference<IUDPSocket>> Sim2::createUDPSocket(NetworkAddress toAddr) {
2484 NetworkAddress localAddress;
2485 auto process = g_simulator.getCurrentProcess();
2486 if (process->address.ip.isV6()) {
2487 IPAddress::IPAddressStore store = process->address.ip.toV6();
2488 uint16_t* ipParts = (uint16_t*)store.data();
2489 ipParts[7] += deterministicRandom()->randomInt(0, 256);
2490 localAddress.ip = IPAddress(store);
2491 } else {
2492 localAddress.ip = IPAddress(process->address.ip.toV4() + deterministicRandom()->randomInt(0, 256));
2493 }
2494 localAddress.port = deterministicRandom()->randomInt(40000, 60000);
2495 while (process->boundUDPSockets.find(localAddress) != process->boundUDPSockets.end()) {
2496 localAddress.port = deterministicRandom()->randomInt(40000, 60000);
2497 }
2498 return Reference<IUDPSocket>(new UDPSimSocket(localAddress, toAddr));
2499}
2500
2501Future<Reference<IUDPSocket>> Sim2::createUDPSocket(bool isV6) {
2502 NetworkAddress localAddress;

Callers 4

_setupMethod · 0.45
prepareMethod · 0.45

Calls 11

deterministicRandomFunction · 0.85
getCurrentProcessMethod · 0.80
toV4Method · 0.80
getMethod · 0.65
IPAddressClass · 0.50
isV6Method · 0.45
dataMethod · 0.45
randomIntMethod · 0.45
findMethod · 0.45
endMethod · 0.45
presentMethod · 0.45

Tested by

no test coverage detected