mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-17 20:40:25 +08:00
调试udp channel,失败
This commit is contained in:
@@ -12,6 +12,7 @@ import security.KeyChain;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.DatagramChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Arrays;
|
||||
@@ -84,11 +85,13 @@ public class LogicFace {
|
||||
*/
|
||||
public boolean initWithUdp(String ip,Integer port) throws LogicFaceException {
|
||||
try {
|
||||
//
|
||||
SocketAddress sa=new InetSocketAddress(ip, port);
|
||||
// Transport
|
||||
DatagramChannel channel=DatagramChannel.open();
|
||||
channel.connect(new InetSocketAddress(ip, port));
|
||||
channel.connect(sa);
|
||||
UdpTransport udpTransport=new UdpTransport();
|
||||
udpTransport.init(channel,new InetSocketAddress(ip, port));
|
||||
udpTransport.init(channel,sa);
|
||||
|
||||
// LinkService
|
||||
this.linkService=new LinkService();
|
||||
|
||||
@@ -39,11 +39,13 @@ public class UdpTransport extends Transport implements ITransport{
|
||||
this.channel=channel;
|
||||
this.localAddr=channel.getLocalAddress().toString();
|
||||
this.localUri="udp://"+this.localAddr;
|
||||
System.out.println("lu: "+this.localUri);
|
||||
|
||||
this.remoteAddr=remoteUdpAddr.toString();
|
||||
this.remoteUri="udp://"+this.remoteAddr;
|
||||
this.recvBuf=new byte[9000];
|
||||
this.remoteUdpAddr=remoteUdpAddr;
|
||||
System.out.println("ru: "+this.remoteUri);
|
||||
} catch (IOException e) {
|
||||
throw new LogicFaceException("UdpTransport.init: "+e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user