MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / bind_random

Method bind_random

src/main/java/core/org/xbill/DNS/UDPClient.java:50–82  ·  view source on GitHub ↗
(InetSocketAddress addr)

Source from the content-addressed store, hash-verified

48}
49
50private void
51bind_random(InetSocketAddress addr) throws IOException
52{
53 if (prng_initializing) {
54 try {
55 Thread.sleep(2);
56 }
57 catch (InterruptedException e) {
58 }
59 if (prng_initializing)
60 return;
61 }
62
63 DatagramChannel channel = (DatagramChannel) key.channel();
64 InetSocketAddress temp;
65
66 for (int i = 0; i < 1024; i++) {
67 try {
68 int port = prng.nextInt(EPHEMERAL_RANGE) +
69 EPHEMERAL_START;
70 if (addr != null)
71 temp = new InetSocketAddress(addr.getAddress(),
72 port);
73 else
74 temp = new InetSocketAddress(port);
75 channel.socket().bind(temp);
76 bound = true;
77 return;
78 }
79 catch (SocketException e) {
80 }
81 }
82}
83
84void
85bind(SocketAddress addr) throws IOException {

Callers 1

bindMethod · 0.95

Calls 2

getAddressMethod · 0.65
bindMethod · 0.45

Tested by

no test coverage detected