• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DatagramSessionConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.mina.transport.socket.DatagramSessionConfig的典型用法代码示例。如果您正苦于以下问题:Java DatagramSessionConfig类的具体用法?Java DatagramSessionConfig怎么用?Java DatagramSessionConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DatagramSessionConfig类属于org.apache.mina.transport.socket包,在下文中一共展示了DatagramSessionConfig类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setupNetwork

import org.apache.mina.transport.socket.DatagramSessionConfig; //导入依赖的package包/类
/***
 * Starts UDP listener and connector.
 */
private void setupNetwork() {
    // Setup server acceptor, since we need to be able to receive incoming packets from the provider
    acceptor = new NioDatagramAcceptor();
    acceptor.setHandler(this);
    DatagramSessionConfig dcfg = (DatagramSessionConfig) acceptor.getSessionConfig();
    dcfg.setReuseAddress(true);
    try {
        logger.info("Trying to listen to {}", this.port);
        acceptor.bind(new InetSocketAddress(this.port));
        logger.info("Listening on port {}", this.port);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    // Setup client connector to provider
    connector = new NioDatagramConnector();
    connector.setHandler(this);
    logger.info("Connecting to {} ({}:{})", this.provider.name, this.provider.host, this.provider.port);
    session = connector.connect(new InetSocketAddress(this.provider.host, this.provider.port))
            .awaitUninterruptibly()
            .getSession();
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:26,代码来源:LoopixClient.java


示例2: init

import org.apache.mina.transport.socket.DatagramSessionConfig; //导入依赖的package包/类
private void init(Config config) {
    address = new InetSocketAddress(config.sourcePort);

    acceptor = new NioDatagramAcceptor();
    acceptor.setHandler(new MinaServerHandler());
    DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
    if (acceptor.getFilterChain().get(LOGGER) == null) {
        chain.addLast(LOGGER, new LoggingFilter());
    }
    if (acceptor.getFilterChain().get(CODEC) == null) {
        ProtocolCodecFactory codecFactory = config.codec == null ?
                MinaUtil.getTextLineCodecFactory() : (ProtocolCodecFactory) config.codec;
        chain.addLast(CODEC, new ProtocolCodecFilter(codecFactory));
    }
    DatagramSessionConfig dcfg = acceptor.getSessionConfig();
    dcfg.setReuseAddress(true);
    dcfg.setReadBufferSize(config.bufferSize);
    dcfg.setIdleTime(IdleStatus.WRITER_IDLE, 10);
    dcfg.setBroadcast(true);

    KeepAliveFilter keepAliveFilter = MinaUtil.initServerKeepAlive(config, this);
    if (keepAliveFilter != null) {
        acceptor.getFilterChain().addLast(HEARTBEAT, keepAliveFilter);
    }
}
 
开发者ID:EthanCo,项目名称:Halo-Turbo,代码行数:26,代码来源:MinaUdpServerSocket.java


示例3: UDPServer

import org.apache.mina.transport.socket.DatagramSessionConfig; //导入依赖的package包/类
private UDPServer(String host, int port) {
    this.host = host;
    this.port = port;
    acceptor = new NioDatagramAcceptor();
    DatagramSessionConfig sessionConfig = acceptor.getSessionConfig();
    sessionConfig.setReuseAddress(true);
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(codecFactory));
    acceptor.getFilterChain().addLast("logger", new LoggingFilter());
    acceptor.setHandler(this);

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:Mina2UdpNoCamelTest.java


示例4: start

import org.apache.mina.transport.socket.DatagramSessionConfig; //导入依赖的package包/类
@Override
public void start() throws IOException {
    acceptor = new NioDatagramAcceptor();
    acceptor.setDefaultLocalAddress(new InetSocketAddress(getPort()));
    acceptor.getFilterChain().addLast("logger-data", new LoggingFilter("tftp-server-data"));
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TftpProtocolCodecFactory()));
    acceptor.getFilterChain().addLast("logger-packet", new LoggingFilter("tftp-server-packet"));
    acceptor.setHandler(new TftpServerProtocolHandler(getDataProvider()));
    DatagramSessionConfig dcfg = acceptor.getSessionConfig();
    dcfg.setReuseAddress(true);
    // dcfg.setIdleTime(IdleStatus.BOTH_IDLE, 5);
    acceptor.bind();
}
 
开发者ID:shevek,项目名称:tftp4j,代码行数:14,代码来源:TftpServer.java


示例5: main

import org.apache.mina.transport.socket.DatagramSessionConfig; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	NioDatagramAcceptor acceptor = new NioDatagramAcceptor();//UDP Acceptor
	acceptor.getFilterChain().addLast("logging", new LoggingFilter());
	acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
	acceptor.getFilterChain().addLast("mdc", new MdcInjectionFilter());
	acceptor.setHandler(new HelloServerHandler());
	acceptor.getSessionConfig().setReadBufferSize(2048);
	acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
	DatagramSessionConfig dcfg = acceptor.getSessionConfig();
	dcfg.setReuseAddress(true);
	acceptor.bind(new InetSocketAddress(PORT));
}
 
开发者ID:ameizi,项目名称:mina-examples,代码行数:13,代码来源:HelloUdpServer.java


示例6: getSessionConfig

import org.apache.mina.transport.socket.DatagramSessionConfig; //导入依赖的package包/类
@Override
public DatagramSessionConfig getSessionConfig() {
    return (DatagramSessionConfig) super.getSessionConfig();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:5,代码来源:NioDatagramAcceptor.java


示例7: getConfig

import org.apache.mina.transport.socket.DatagramSessionConfig; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public DatagramSessionConfig getConfig() {
    return (DatagramSessionConfig) config;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:NioDatagramSession.java


示例8: PeerlessUdpServer

import org.apache.mina.transport.socket.DatagramSessionConfig; //导入依赖的package包/类
public PeerlessUdpServer(PeerlessDbSupport peerlessDbSupport, SigHashTable sht) throws IOException {
	
	this.sht=sht;
	this.peerlessDbSupport=peerlessDbSupport;

    NioDatagramAcceptor acceptor = new NioDatagramAcceptor();
    acceptor.setHandler(new PeerlessUdpServerHandler(this));

    DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
    chain.addLast("logger", new LoggingFilter());

    DatagramSessionConfig dcfg = acceptor.getSessionConfig();
    dcfg.setReuseAddress(true);

 chain.addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));        
    
     acceptor.bind(new InetSocketAddress(PORT));
    System.out.println("UDPServer listening on port " + PORT);
}
 
开发者ID:knowpd,项目名称:p2p-file-sharing-system,代码行数:20,代码来源:PeerlessUdpServer.java



注:本文中的org.apache.mina.transport.socket.DatagramSessionConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JavaBeansMetaModel类代码示例发布时间:2022-05-23
下一篇:
Java ConnectionHandshakeException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap