public class UdpServer<T> extends UdpClient<T>
支持异步和同步模式
同步模式不需要设置 MessageListener;要求一问一答模式,即发送请求,回复请求,可以配合超时时间,默认2s
异步模式需要设置 MessageListener,不严格要求是一问一答模式,有消息收到就会进入回调函数
bindPort, channel, channelClass, clientMessageHandler, connectTimeout, enableNetLog, eventLoop, heartbeatTime, host, LOCK, messageListener, packetCoderHandlerFactory, port, reconnectWait, result, sync, timeout| 构造器和说明 |
|---|
UdpServer(int bindPort)
Constructor for UdpServer.
|
UdpServer(String host,
int port,
int bindPort)
Constructor for UdpServer.
|
| 限定符和类型 | 方法和说明 |
|---|---|
T |
send(ConnectionContext<T> ctx,
T t)
send.
|
T |
send(InetSocketAddress address,
T t)
send.
|
T |
send(String host,
int port,
T t)
发送数据
|
void |
setPacketCoder(PacketCoder<T> packetCoder) |
sendBroadcastawait, close, connect, doSend, getBindPort, getHost, getPort, getReconnectWait, init, isConnected, loopConnect, preDestroy, send, setAutoReconnect, setConnectTimeout, setEnableNetLog, setEventListener, setHeartbeatTime, setMessageListener, setReconnectWait, setSync, setTimeout, signalAll, startpublic UdpServer(String host, int port, int bindPort)
Constructor for UdpServer.
host - a String object.port - a int.bindPort - a int.public UdpServer(int bindPort)
Constructor for UdpServer.
bindPort - a int.public void setPacketCoder(PacketCoder<T> packetCoder)
setPacketCoder 在类中 UdpClient<T>public T send(String host, int port, T t)
host - 要发送的 hostport - 要发送的端口t - 要发送的内容public T send(ConnectionContext<T> ctx, T t)
send.
ctx - a ConnectionContext object.t - a T object.public T send(InetSocketAddress address, T t)
send.
address - a InetSocketAddress object.t - a T object.Copyright © 2023. All rights reserved.