本文整理汇总了Java中io.netty.channel.socket.InternetProtocolFamily类的典型用法代码示例。如果您正苦于以下问题:Java InternetProtocolFamily类的具体用法?Java InternetProtocolFamily怎么用?Java InternetProtocolFamily使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InternetProtocolFamily类属于io.netty.channel.socket包,在下文中一共展示了InternetProtocolFamily类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: MulticastSeedNodeProvider
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
/**
* Constructs new instance.
*
* @param cfg Configuration.
*
* @throws UnknownHostException If failed to resolve multicast group address.
*/
public MulticastSeedNodeProvider(MulticastSeedNodeProviderConfig cfg) throws UnknownHostException {
ConfigCheck check = ConfigCheck.get(getClass());
check.notNull(cfg, "configuration");
check.positive(cfg.getPort(), "port");
check.nonNegative(cfg.getTtl(), "TTL");
check.notEmpty(cfg.getGroup(), "multicast group");
check.positive(cfg.getInterval(), "discovery interval");
check.positive(cfg.getWaitTime(), "wait time");
check.that(cfg.getInterval() < cfg.getWaitTime(), "discovery interval must be greater than wait time "
+ "[discovery-interval=" + cfg.getInterval() + ", wait-time=" + cfg.getWaitTime() + ']');
InetAddress groupAddress = InetAddress.getByName(cfg.getGroup());
check.isTrue(groupAddress.isMulticastAddress(), "address is not a multicast address [address=" + groupAddress + ']');
group = new InetSocketAddress(groupAddress, cfg.getPort());
ttl = cfg.getTtl();
interval = cfg.getInterval();
waitTime = cfg.getWaitTime();
loopBackDisabled = cfg.isLoopBackDisabled();
ipVer = group.getAddress() instanceof Inet6Address ? InternetProtocolFamily.IPv6 : InternetProtocolFamily.IPv4;
}
开发者ID:hekate-io,项目名称:hekate,代码行数:32,代码来源:MulticastSeedNodeProvider.java
示例2: subscribe
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
@Override
public void subscribe(final Subscriber<? super O> subscriber) {
try {
final List<NetworkInterface> interfaces = Collections
.list(NetworkInterface.getNetworkInterfaces());
UdpServer
.create(opts ->
opts.option(ChannelOption.SO_REUSEADDR, true)
.connectAddress(() -> new InetSocketAddress(this.port))
.protocolFamily(InternetProtocolFamily.IPv4))
.newHandler((in, out) -> {
Flux.fromIterable(interfaces)
.flatMap(iface -> in.join(this.address, iface))
.thenMany(in.receive().asByteArray())
.map(this.parser)
.subscribe(subscriber);
return Flux.never();
})
.subscribe();
} catch (final SocketException exception) {
Flux.<O>error(exception).subscribe(subscriber);
}
}
开发者ID:delta-leonis,项目名称:zosma,代码行数:25,代码来源:MulticastPublisher.java
示例3: MulticastServerHandler
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
public MulticastServerHandler(Cluster cluster, InetSocketAddress address) throws InterruptedException {
this.address = address;
handler = new Bootstrap()
.channelFactory(() -> new NioDatagramChannel(InternetProtocolFamily.IPv4))
.localAddress(address)
.group(new NioEventLoopGroup())
.option(ChannelOption.SO_REUSEADDR, true)
.option(ChannelOption.IP_MULTICAST_IF, multicastInterface)
.option(ChannelOption.AUTO_READ, false)
.handler(new ChannelInitializer<NioDatagramChannel>() {
@Override
public void initChannel(NioDatagramChannel ch) throws Exception {
ch.pipeline().addLast(new MulticastChannelAdapter(cluster));
}
});
localMember = cluster.getLocalMember();
}
开发者ID:buremba,项目名称:kume,代码行数:19,代码来源:MulticastServerHandler.java
示例4: subscribe
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
@Override
public void subscribe(final Subscriber<? super DatagramPacket> subscriber) {
UdpClient
.create(opts -> opts
.option(ChannelOption.SO_REUSEADDR, true)
.port(this.port)
.protocolFamily(InternetProtocolFamily.IPv4))
.newHandler((in, out) -> {
in.receive().asByteArray()
.map(bytes -> new DatagramPacket(bytes, bytes.length))
.subscribe(subscriber);
return Flux.never();
})
.subscribe();
}
开发者ID:delta-leonis,项目名称:zosma,代码行数:16,代码来源:UDPPublisher.java
示例5: newChannel
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
@Override
public T newChannel() {
try {
return ReflectionUtils.instantiateWithCustomCtor(clazz.getName(),
new Class[] { InternetProtocolFamily.class }, new Object[] { family });
} catch (Throwable t) {
throw new ChannelException("Unable to create Channel from class " + clazz, t);
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:ClusterStatusPublisher.java
示例6: datagram
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
public List<BootstrapComboFactory<Bootstrap, Bootstrap>> datagram() {
// Make the list of Bootstrap factories.
List<BootstrapFactory<Bootstrap>> bfs = Arrays.asList(
new BootstrapFactory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(nioWorkerGroup).channelFactory(new ChannelFactory<Channel>() {
@Override
public Channel newChannel() {
return new NioDatagramChannel(InternetProtocolFamily.IPv4);
}
@Override
public String toString() {
return NioDatagramChannel.class.getSimpleName() + ".class";
}
});
}
},
new BootstrapFactory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(oioWorkerGroup).channel(OioDatagramChannel.class);
}
}
);
// Populare the combinations.
return combo(bfs, bfs);
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:31,代码来源:SocketTestPermutation.java
示例7: convert
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
/**
* 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();
}
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:14,代码来源:ProtocolFamilyConverter.java
示例8: newSocket
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
private static DatagramChannel newSocket(SelectorProvider provider, InternetProtocolFamily ipFamily) {
if (ipFamily == null) {
return newSocket(provider);
}
checkJavaVersion();
try {
return provider.openDatagramChannel(ProtocolFamilyConverter.convert(ipFamily));
} catch (IOException e) {
throw new ChannelException("Failed to open a socket.", e);
}
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:14,代码来源:NioDatagramChannel.java
示例9: datagram
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
@Override
public List<TestsuitePermutation.BootstrapComboFactory<Bootstrap, Bootstrap>> datagram() {
// Make the list of Bootstrap factories.
List<BootstrapFactory<Bootstrap>> bfs = Arrays.asList(
new BootstrapFactory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(nioWorkerGroup).channelFactory(new ChannelFactory<Channel>() {
@Override
public Channel newChannel() {
return new NioDatagramChannel(InternetProtocolFamily.IPv4);
}
@Override
public String toString() {
return NioDatagramChannel.class.getSimpleName() + ".class";
}
});
}
},
new BootstrapFactory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(EPOLL_WORKER_GROUP).channel(EpollDatagramChannel.class);
}
}
);
return combo(bfs, bfs);
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:30,代码来源:EpollSocketTestPermutation.java
示例10: newSocket
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
private static DatagramChannel newSocket(InternetProtocolFamily ipFamily) {
if (ipFamily == null) {
return newSocket();
}
if (PlatformDependent.javaVersion() < 7) {
throw new UnsupportedOperationException();
}
try {
return DatagramChannel.open(ProtocolFamilyConverter.convert(ipFamily));
} catch (IOException e) {
throw new ChannelException("Failed to open a socket.", e);
}
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:16,代码来源:NioDatagramChannel.java
示例11: DataServerThread
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
public DataServerThread() {
dataBossGroup = new NioEventLoopGroup(DATA_BOSS_THREADS);
dataWorkerGroup = new NioEventLoopGroup(DATA_WORKER_THREADS);
try {
Bootstrap b = new Bootstrap();
b.group(dataWorkerGroup)
.channelFactory(new ChannelFactory<Channel>() {
@Override
public Channel newChannel() {
return new NioDatagramChannel(InternetProtocolFamily.IPv4);
}
@Override
public String toString() {
return NioDatagramChannel.class.getSimpleName() + ".class";
}
}).handler(new ChannelInitializer<DatagramChannel>() {
@Override
public void initChannel(DatagramChannel ch) throws Exception {
ch.config().setAllocator(UnpooledByteBufAllocator.DEFAULT);
ch.pipeline().addLast(new DataMessageHandler());
if (LOG.isTraceEnabled()) {
ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
LOG.error("Cannot initialize data server.", cause);
}
});
// Bind and start to accept incoming connections.
f = b.bind(getIp(), getDataPort()).sync();
} catch (InterruptedException ex) {
LOG.error("Message data interrupted.", ex);
}
}
开发者ID:Archarithms,项目名称:bigio,代码行数:39,代码来源:MeMemberUDP.java
示例12: HBaseDatagramChannelFactory
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
HBaseDatagramChannelFactory(Class<? extends T> clazz, InternetProtocolFamily family) {
this.clazz = clazz;
this.family = family;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:5,代码来源:ClusterStatusPublisher.java
示例13: NioDatagramChannelFactory
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
public NioDatagramChannelFactory(InternetProtocolFamily ipFamily) {
this.ipFamily = ipFamily;
}
开发者ID:FIWARE-Middleware,项目名称:KIARA,代码行数:4,代码来源:NioDatagramChannelFactory.java
示例14: datagram
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
static List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> datagram() {
List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> list =
new ArrayList<Entry<Factory<Bootstrap>, Factory<Bootstrap>>>();
// Make the list of Bootstrap factories.
List<Factory<Bootstrap>> bfs =
new ArrayList<Factory<Bootstrap>>();
bfs.add(new Factory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(nioWorkerGroup).channelFactory(new ChannelFactory<Channel>() {
@Override
public Channel newChannel() {
return new NioDatagramChannel(InternetProtocolFamily.IPv4);
}
@Override
public String toString() {
return NioDatagramChannel.class.getSimpleName() + ".class";
}
});
}
});
bfs.add(new Factory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(oioWorkerGroup).channel(OioDatagramChannel.class);
}
});
// Populate the combinations
for (Factory<Bootstrap> sbf: bfs) {
for (Factory<Bootstrap> cbf: bfs) {
final Factory<Bootstrap> sbf0 = sbf;
final Factory<Bootstrap> cbf0 = cbf;
list.add(new Entry<Factory<Bootstrap>, Factory<Bootstrap>>() {
@Override
public Factory<Bootstrap> getKey() {
return sbf0;
}
@Override
public Factory<Bootstrap> getValue() {
return cbf0;
}
@Override
public Factory<Bootstrap> setValue(Factory<Bootstrap> value) {
throw new UnsupportedOperationException();
}
});
}
}
return list;
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:57,代码来源:SocketTestPermutation.java
示例15: datagram
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
static List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> datagram() {
List<Entry<Factory<Bootstrap>, Factory<Bootstrap>>> list =
new ArrayList<Entry<Factory<Bootstrap>, Factory<Bootstrap>>>();
// Make the list of Bootstrap factories.
List<Factory<Bootstrap>> bfs = new ArrayList<Factory<Bootstrap>>();
bfs.add(new Factory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(nioWorkerGroup).channelFactory(new ChannelFactory<Channel>() {
@Override
public Channel newChannel(EventLoop eventLoop) {
return new NioDatagramChannel(eventLoop, InternetProtocolFamily.IPv4);
}
@Override
public String toString() {
return NioDatagramChannel.class.getSimpleName() + ".class";
}
});
}
});
bfs.add(new Factory<Bootstrap>() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(oioWorkerGroup).channel(OioDatagramChannel.class);
}
});
// Populate the combinations
for (Factory<Bootstrap> sbf: bfs) {
for (Factory<Bootstrap> cbf: bfs) {
final Factory<Bootstrap> sbf0 = sbf;
final Factory<Bootstrap> cbf0 = cbf;
list.add(new Entry<Factory<Bootstrap>, Factory<Bootstrap>>() {
@Override
public Factory<Bootstrap> getKey() {
return sbf0;
}
@Override
public Factory<Bootstrap> getValue() {
return cbf0;
}
@Override
public Factory<Bootstrap> setValue(Factory<Bootstrap> value) {
throw new UnsupportedOperationException();
}
});
}
}
return list;
}
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:56,代码来源:SocketTestPermutation.java
示例16: NioDatagramChannel
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
/**
* Create a new instance using the given {@link InternetProtocolFamily}. If {@code null} is used it will depend
* on the Operation Systems default which will be chosen.
*/
public NioDatagramChannel(InternetProtocolFamily ipFamily) {
this(newSocket(DEFAULT_SELECTOR_PROVIDER, ipFamily));
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:8,代码来源:NioDatagramChannel.java
示例17: NioDatagramChannel
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
/**
* Create a new instance using the given {@link InternetProtocolFamily}. If {@code null} is used it will depend
* on the Operation Systems default which will be chosen.
*/
public NioDatagramChannel(InternetProtocolFamily ipFamily) {
this(newSocket(ipFamily));
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:8,代码来源:NioDatagramChannel.java
示例18: NioDatagramChannel
import io.netty.channel.socket.InternetProtocolFamily; //导入依赖的package包/类
/**
* Create a new instance using the given {@link InternetProtocolFamily}. If {@code null} is used it will depend
* on the Operation Systems default which will be chosen.
*/
public NioDatagramChannel(EventLoop eventLoop, InternetProtocolFamily ipFamily) {
this(eventLoop, newSocket(ipFamily));
}
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:8,代码来源:NioDatagramChannel.java
注:本文中的io.netty.channel.socket.InternetProtocolFamily类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论