本文整理汇总了Java中org.jboss.netty.channel.Channel.getLocalAddress方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.getLocalAddress方法的具体用法?Java Channel.getLocalAddress怎么用?Java Channel.getLocalAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.netty.channel.Channel
的用法示例。
在下文中一共展示了Channel.getLocalAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServer
import org.jboss.netty.channel.Channel; //导入方法依赖的package包/类
private String getServer(Channel channel) {
String server = Context.getConfig().getString(getProtocolName() + ".server");
if (server == null) {
InetSocketAddress address = (InetSocketAddress) channel.getLocalAddress();
server = address.getAddress().getHostAddress() + ":" + address.getPort();
}
return server;
}
示例2: getLocalSocketAddress
import org.jboss.netty.channel.Channel; //导入方法依赖的package包/类
@Override
SocketAddress getLocalSocketAddress() {
Channel copiedChanRef = channel;
return (copiedChanRef == null) ? null : copiedChanRef.getLocalAddress();
}
示例3: setUp
import org.jboss.netty.channel.Channel; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
peer1 = new BgpPeerTest(version, asNumber,
holdTime, bgpId, isLargeAsCapabilitySet,
capabilityTlv);
peer2 = new BgpPeerTest(version, asNumber,
holdTime, bgpId, isLargeAsCapabilitySet,
capabilityTlv);
bgpControllerImpl = new BgpControllerImpl();
// NOTE: We use port 0 to bind on any available port
bgpControllerImpl.controller().setBgpPortNum();
bgpControllerImpl.activate();
Channel serverChannel = TestUtils.getField(bgpControllerImpl.controller(),
"serverChannel");
SocketAddress socketAddress = serverChannel.getLocalAddress();
InetSocketAddress inetSocketAddress =
(InetSocketAddress) socketAddress;
InetAddress connectToAddress = InetAddresses.forString("127.0.0.1");
connectToSocket = new InetSocketAddress(connectToAddress,
inetSocketAddress.getPort());
bgpControllerImpl.getConfig().setRouterId("1.1.1.1");
bgpControllerImpl.getConfig().setAsNumber(200);
bgpControllerImpl.getConfig().setHoldTime((short) 120);
bgpControllerImpl.getConfig().setState(BgpCfg.State.IP_AS_CONFIGURED);
bgpControllerImpl.getConfig().addPeer("127.0.0.1", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.9", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.33", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.10", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.20", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.30", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.40", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.50", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.60", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.70", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.80", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.90", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.91", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.92", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.99", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.94", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.95", 200);
bgpControllerImpl.getConfig().addPeer("127.0.0.35", 200);
}
示例4: setUp
import org.jboss.netty.channel.Channel; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
peer1 = new TestBgpPeer(BGP_PEER1_ID);
peer2 = new TestBgpPeer(BGP_PEER2_ID);
peer3 = new TestBgpPeer(BGP_PEER3_ID);
peers.clear();
peers.add(peer1);
peers.add(peer2);
peers.add(peer3);
//
// Setup the BGP Session Manager to test, and start listening for BGP
// connections.
//
bgpSessionManager = new BgpSessionManager();
routeService = createNiceMock(RouteAdminService.class);
replay(routeService);
bgpSessionManager.routeService = routeService;
// NOTE: We use port 0 to bind on any available port
ComponentContext componentContext = createMock(ComponentContext.class);
getDictionaryMock(componentContext);
replay(componentContext);
bgpSessionManager.activate(componentContext);
// Get the port number the BGP Session Manager is listening on
Channel serverChannel = TestUtils.getField(bgpSessionManager,
"serverChannel");
SocketAddress socketAddress = serverChannel.getLocalAddress();
InetSocketAddress inetSocketAddress =
(InetSocketAddress) socketAddress;
InetAddress connectToAddress = InetAddresses.forString("127.0.0.1");
connectToSocket = new InetSocketAddress(connectToAddress,
inetSocketAddress.getPort());
//
// Setup the AS Paths
//
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
byte pathSegmentType1 = (byte) BgpConstants.Update.AsPath.AS_SEQUENCE;
ArrayList<Long> segmentAsNumbers1 = new ArrayList<>();
segmentAsNumbers1.add(65010L);
segmentAsNumbers1.add(65020L);
segmentAsNumbers1.add(65030L);
BgpRouteEntry.PathSegment pathSegment1 =
new BgpRouteEntry.PathSegment(pathSegmentType1, segmentAsNumbers1);
pathSegments.add(pathSegment1);
asPathShort = new BgpRouteEntry.AsPath(new ArrayList<>(pathSegments));
//
byte pathSegmentType2 = (byte) BgpConstants.Update.AsPath.AS_SET;
ArrayList<Long> segmentAsNumbers2 = new ArrayList<>();
segmentAsNumbers2.add(65041L);
segmentAsNumbers2.add(65042L);
segmentAsNumbers2.add(65043L);
BgpRouteEntry.PathSegment pathSegment2 =
new BgpRouteEntry.PathSegment(pathSegmentType2, segmentAsNumbers2);
pathSegments.add(pathSegment2);
//
asPathLong = new BgpRouteEntry.AsPath(pathSegments);
}