-
Notifications
You must be signed in to change notification settings - Fork 262
Expand file tree
/
Copy pathDefaultIoClient.java
More file actions
46 lines (41 loc) · 1.21 KB
/
DefaultIoClient.java
File metadata and controls
46 lines (41 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: BSD-3-Clause
package org.xbill.DNS;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import org.xbill.DNS.io.TcpIoClient;
import org.xbill.DNS.io.UdpIoClient;
/**
* An implementation of the IO clients that use the internal NIO-based clients.
*
* @see NioUdpClient
* @see NioTcpClient
* @since 3.6
*/
public class DefaultIoClient implements TcpIoClient, UdpIoClient {
private final TcpIoClient tcpIoClient;
private final UdpIoClient udpIoClient;
public DefaultIoClient() {
tcpIoClient = new NioTcpClient();
udpIoClient = new NioUdpClient();
}
@Override
public CompletableFuture<byte[]> sendAndReceiveTcp(
InetSocketAddress local,
InetSocketAddress remote,
Message query,
byte[] data,
Duration timeout) {
return tcpIoClient.sendAndReceiveTcp(local, remote, query, data, timeout);
}
@Override
public CompletableFuture<byte[]> sendAndReceiveUdp(
InetSocketAddress local,
InetSocketAddress remote,
Message query,
byte[] data,
int max,
Duration timeout) {
return udpIoClient.sendAndReceiveUdp(local, remote, query, data, max, timeout);
}
}