From 5bd35d38fe63c149988a32d07d39ba5dc1e139c4 Mon Sep 17 00:00:00 2001 From: kamhung <22250530@qq.com> Date: Thu, 12 Nov 2015 18:05:27 +0800 Subject: [PATCH] --- src/com/wentch/redkale/net/Transport.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/wentch/redkale/net/Transport.java b/src/com/wentch/redkale/net/Transport.java index 4b84243d3..6f63fa7d1 100644 --- a/src/com/wentch/redkale/net/Transport.java +++ b/src/com/wentch/redkale/net/Transport.java @@ -30,6 +30,8 @@ public final class Transport { protected final int bufferCapacity; + protected final boolean tcp; + protected final String protocol; protected final AsynchronousChannelGroup group; @@ -49,6 +51,7 @@ public final class Transport { public Transport(String name, String protocol, WatchFactory watch, int bufferPoolSize, Collection addresses) { this.name = name; this.protocol = protocol; + this.tcp = "TCP".equalsIgnoreCase(protocol); this.bufferPoolSize = bufferPoolSize; this.bufferCapacity = 8192; AsynchronousChannelGroup g = null; @@ -129,7 +132,7 @@ public final class Transport { } public boolean isTCP() { - return "TCP".equalsIgnoreCase(protocol); + return tcp; } public AsyncConnection pollConnection(SocketAddress addr) { @@ -137,7 +140,7 @@ public final class Transport { final boolean rand = addr == null; if (rand && remoteAddres.length < 1) throw new RuntimeException("Transport (" + this.name + ") has no remoteAddress list"); try { - if ("TCP".equalsIgnoreCase(protocol)) { + if (tcp) { AsynchronousSocketChannel channel = null; if (rand) { //随机取地址 int p = 0;