@Before
public void setUp() throws Exception {
reactor = new NioReactor();
crusher = DatagramCrusherBuilder.builder()
.withReactor(reactor)
.withBindAddress(ADDR_LOOPBACK6, PORT_DIRECT)
.withConnectAddress(ADDR_LOOPBACK6, PORT_PROXY)
.withProtocolFamily(StandardProtocolFamily.INET6)
.withCreationListener((addr) -> LOGGER.info("Client is created <{}>", addr))
.withDeletionListener((addr, byteMeters, packetMeters) -> LOGGER.info("Client is deleted <{}>", addr))
.buildAndOpen();
}
java类java.net.StandardProtocolFamily的实例源码
CrusherDatagramSocat6Test.java 文件源码
项目:netcrusher-java
阅读 14
收藏 0
点赞 0
评论 0
CrusherDatagramSocat4Test.java 文件源码
项目:netcrusher-java
阅读 15
收藏 0
点赞 0
评论 0
@Before
public void setUp() throws Exception {
reactor = new NioReactor();
crusher = DatagramCrusherBuilder.builder()
.withReactor(reactor)
.withBindAddress(ADDR_LOOPBACK4, PORT_DIRECT)
.withConnectAddress(ADDR_LOOPBACK4, PORT_PROXY)
.withProtocolFamily(StandardProtocolFamily.INET)
.withCreationListener((addr) -> LOGGER.info("Client is created <{}>", addr))
.withDeletionListener((addr, byteMeters, packetMeters) -> LOGGER.info("Client is deleted <{}>", addr))
.buildAndOpen();
}
DatagramBulkReflector.java 文件源码
项目:netcrusher-java
阅读 15
收藏 0
点赞 0
评论 0
public DatagramBulkReflector(String name, InetSocketAddress bindAddress,
long limit,
CyclicBarrier readBarrier) throws IOException {
this.channel = DatagramChannel.open(StandardProtocolFamily.INET);
this.channel.configureBlocking(true);
this.channel.bind(bindAddress);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Bulk reflector {}: BIND<{}>", new Object[]{name, bindAddress});
}
this.reflector = new Reflector(channel, name, limit, readBarrier);
}
ExampleApplication.java 文件源码
项目:angler
阅读 21
收藏 0
点赞 0
评论 0
private static DatagramChannel multicastListener(final InetAddress address, final int port) throws IOException
{
final NetworkInterface networkInterface = getMulticastCapableNetworkInterface();
final DatagramChannel channel = DatagramChannel.open(StandardProtocolFamily.INET);
channel.bind(new InetSocketAddress(address, port));
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, networkInterface);
channel.join(address, networkInterface);
return channel;
}
ExampleApplication.java 文件源码
项目:angler
阅读 21
收藏 0
点赞 0
评论 0
private static DatagramChannel createListeningChannelOnPort(final InetSocketAddress local) throws IOException
{
return DatagramChannel.open(StandardProtocolFamily.INET).
setOption(StandardSocketOptions.SO_REUSEADDR, true).
setOption(StandardSocketOptions.SO_RCVBUF, 4096).
bind(local);
}
ProtocolFamilyConverter.java 文件源码
项目:netty4.0.27Learn
阅读 19
收藏 0
点赞 0
评论 0
/**
* Convert the {@link InternetProtocolFamily}. This MUST only be called on jdk version >= 7.
*/
public static ProtocolFamily convert(InternetProtocolFamily family) {
switch (family) {
case IPv4:
return StandardProtocolFamily.INET;
case IPv6:
return StandardProtocolFamily.INET6;
default:
throw new IllegalArgumentException();
}
}
BasicMulticastSocketHandler.java 文件源码
项目:wot_gateways
阅读 16
收藏 0
点赞 0
评论 0
public BasicMulticastSocketHandler(ChannelManager channelManager)
throws IOException {
this.channelManager = channelManager;
mcastChannel = DatagramChannel.open(StandardProtocolFamily.INET);
mcastChannel.socket().bind(new InetSocketAddress(0)); // port can be 0,
// then a free
// port is
// chosen
this.localPort = mcastChannel.socket().getLocalPort();
mcastChannel.configureBlocking(false);
workerThread = new WorkerThread();
workerThread.start();
}
AutoDetectingServerConfig.java 文件源码
项目:eborp
阅读 13
收藏 0
点赞 0
评论 0
private DatagramChannel createReceiveChannel() throws IOException {
final String nicName = properties.getProperty(PropertiesReader.NETWORK_INTERFACE);
final NetworkInterface networkInterface = getNetworkInterface(nicName);
final DatagramChannel channel = DatagramChannel.open(StandardProtocolFamily.INET);
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true)
.bind(new InetSocketAddress(ANNOUNCE_PORT))
.setOption(StandardSocketOptions.IP_MULTICAST_IF, networkInterface);
final InetAddress group = InetAddress.getByName(MULTICAST_GROUP);
channel.join(group, networkInterface);
return channel;
}
UdpDataSink.java 文件源码
项目:eborp
阅读 16
收藏 0
点赞 0
评论 0
public UdpDataSink(ServerConfig serverConfig) {
System.out.println("Opening UDP channel for sending");
try {
channel = DatagramChannel.open(StandardProtocolFamily.INET);
channel.connect(new InetSocketAddress(serverConfig.getInetAddress(), serverConfig.getPort()));
} catch (IOException e) {
throw new IllegalStateException("Unable to start UDP channel for sending", e);
}
}
SsdpChannel.java 文件源码
项目:nls-net-ssdp
阅读 15
收藏 0
点赞 0
评论 0
private DatagramChannel createChannel(NetworkInterface networkIf, InetSocketAddress address, SsdpSelector selector)
throws IOException {
DatagramChannel channel = DatagramChannel.open(StandardProtocolFamily.INET)
.setOption(StandardSocketOptions.SO_REUSEADDR, true)
.bind(address)
.setOption(StandardSocketOptions.IP_MULTICAST_IF, networkIf);
channel.join(SSDP_MCAST_ADDRESS.getAddress(), networkIf);
channel.configureBlocking(false);
selector.register(this, channel);
return channel;
}