本文整理匯總了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);
}