当前位置: 首页>>代码示例>>Java>>正文


Java SocketAcceptor.bind方法代码示例

本文整理汇总了Java中org.apache.mina.transport.socket.nio.SocketAcceptor.bind方法的典型用法代码示例。如果您正苦于以下问题:Java SocketAcceptor.bind方法的具体用法?Java SocketAcceptor.bind怎么用?Java SocketAcceptor.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mina.transport.socket.nio.SocketAcceptor的用法示例。


在下文中一共展示了SocketAcceptor.bind方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run_startup_configurations

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public static void run_startup_configurations() {
    ip = ServerConfig.IP_ADDRESS + ":" + PORT;

    ByteBuffer.setUseDirectBuffers(false);
    ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

    acceptor = new SocketAcceptor();
    final SocketAcceptorConfig cfg = new SocketAcceptorConfig();
    cfg.getSessionConfig().setTcpNoDelay(true);
    cfg.setDisconnectOnUnbind(true);
    cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory()));
    players = new PlayerStorage(-10);

    try {
        InetSocketadd = new InetSocketAddress(PORT);
        acceptor.bind(InetSocketadd, new MapleServerHandler(), cfg);
        System.out.println("Cash Shop Server is listening on port " + PORT + ".");
    } catch (final IOException e) {
        System.out.println(" Failed!");
        System.err.println("Could not bind to port " + PORT + ".");
        throw new RuntimeException("Binding failed.", e);
    }
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:24,代码来源:CashShopServer.java

示例2: run_startup_configurations

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public static final void run_startup_configurations() {
    userLimit = ServerConfig.USER_LIMIT;
    serverName = ServerConfig.SERVER_NAME;
    eventMessage = ServerConfig.EVENT_MSG;
    maxCharacters = ServerConfig.MAX_CHARACTERS;

    ByteBuffer.setUseDirectBuffers(false);
    ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

    acceptor = new SocketAcceptor();
    final SocketAcceptorConfig cfg = new SocketAcceptorConfig();
    cfg.getSessionConfig().setTcpNoDelay(true);
    cfg.setDisconnectOnUnbind(true);
    cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory()));

    try {
        InetSocketadd = new InetSocketAddress(8484);
        acceptor.bind(InetSocketadd, new MapleServerHandler(), cfg);
        System.out.println("Login Server is listening on port 8484.");
    } catch (IOException e) {
        System.out.println(" Failed!");
        System.err.println("Could not bind to port 8484: " + e);
    }
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:25,代码来源:LoginServer.java

示例3: run_startup_configurations

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public static void run_startup_configurations() {
    System.out.print("Loading Cash Shop...");
    ip = ServerConfig.interface_ + ":" + PORT;

    ByteBuffer.setUseDirectBuffers(false);
    ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

    acceptor = new SocketAcceptor();
    final SocketAcceptorConfig cfg = new SocketAcceptorConfig();
    cfg.getSessionConfig().setTcpNoDelay(true);
    cfg.setDisconnectOnUnbind(true);
    cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory()));
    players = new PlayerStorage(-10);

    try {
        InetSocketadd = new InetSocketAddress(PORT);
        acceptor.bind(InetSocketadd, new MapleServerHandler(), cfg);
        System.out.println(" Complete!");
        System.out.println("Cash Shop Server is listening on port " + PORT + ".");
    } catch (final IOException e) {
        System.out.println(" Failed!");
        System.err.println("Could not bind to port " + PORT + ".");
        throw new RuntimeException("Binding failed.", e);
    }
}
 
开发者ID:skorch37,项目名称:Asteria,代码行数:26,代码来源:CashShopServer.java

示例4: run_startup_configurations

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public static void run_startup_configurations() {
    ip = ServerConfig.interface_ + ":" + PORT;

    ByteBuffer.setUseDirectBuffers(false);
    ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

    acceptor = new SocketAcceptor();
    SocketAcceptorConfig cfg = new SocketAcceptorConfig();
    cfg.getSessionConfig().setTcpNoDelay(true);
    cfg.setDisconnectOnUnbind(true);
    cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory()));
    players = new PlayerStorage(-30);
    try {
        InetSocketadd = new InetSocketAddress(8601);
        acceptor.bind(InetSocketadd, new MapleServerHandler(), cfg);
        System.out.println("Farm Server is listening on port 8601.");
    } catch (IOException e) {
        System.err.println("Binding to port 8601 failed");
        throw new RuntimeException("Binding failed.", e);
    }
}
 
开发者ID:skorch37,项目名称:Asteria,代码行数:22,代码来源:FarmServer.java

示例5: doOpen

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
@Override
protected void doOpen() throws Throwable {
    // set thread pool.
    acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
                                   Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker",
                                                                                        true)));
    // config
    SocketAcceptorConfig cfg = (SocketAcceptorConfig) acceptor.getDefaultConfig();
    cfg.setThreadModel(ThreadModel.MANUAL);
    // set codec.
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
    
    acceptor.bind(getBindAddress(), new MinaHandler(getUrl(), this));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:15,代码来源:MinaServer.java

示例6: start

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public void start() throws Exception {
    acceptor = new SocketAcceptor();

    // Prepare the configuration
    SocketAcceptorConfig cfg = new SocketAcceptorConfig();
    cfg.setReuseAddress(true);
    Charset charset = Charset.forName("UTF-8");
    cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(charset)));

    // Bind
    acceptor.bind(new InetSocketAddress(port), new ReverseProtocolHandler(), cfg);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:ReverserServer.java

示例7: accept

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public void accept(final NetworkTransportConfiguration config, final ProtocolEngineFactory factory,
        final SSLContextFactory sslFactory)
{
    int processors = config.getConnectorProcessors();
    
    if (Transport.TCP.equalsIgnoreCase(config.getTransport()))
    {
        _acceptor = new SocketAcceptor(processors, new NewThreadExecutor());

        SocketAcceptorConfig sconfig = (SocketAcceptorConfig) _acceptor.getDefaultConfig();
        sconfig.setThreadModel(ExecutorThreadModel.getInstance("MinaNetworkTransport(Acceptor)"));
        SocketSessionConfig sc = (SocketSessionConfig) sconfig.getSessionConfig();
        sc.setTcpNoDelay(config.getTcpNoDelay());
        sc.setSendBufferSize(config.getSendBufferSize());
        sc.setReceiveBufferSize(config.getReceiveBufferSize());

        if (config.getHost().equals(WILDCARD_ADDRESS))
        {
            _address = new InetSocketAddress(config.getPort());
        }
        else
        {
            _address = new InetSocketAddress(config.getHost(), config.getPort());
        }
    }
    else
    {
        throw new TransportException("Unknown transport: " + config.getTransport());
    }

    try
    {
        _acceptor.bind(_address, new MinaNetworkHandler(sslFactory, factory));
    }
    catch (IOException e)
    {
        throw new TransportException("Could not bind to " + _address, e);
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:40,代码来源:MinaNetworkTransport.java

示例8: doOpen

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
@Override
protected void doOpen() throws Throwable {
    // set thread pool.
    acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
            Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker",
                    true)));
    // config
    SocketAcceptorConfig cfg = (SocketAcceptorConfig) acceptor.getDefaultConfig();
    cfg.setThreadModel(ThreadModel.MANUAL);
    // set codec.
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));

    acceptor.bind(getBindAddress(), new MinaHandler(getUrl(), this));
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:15,代码来源:MinaServer.java

示例9: run_startup_configurations

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public static final void run_startup_configurations() {
    System.out.print("Loading Login Server...");
    userLimit = ServerConfig.userLimit;
    serverName = ServerConfig.serverName;
    eventMessage = ServerConfig.eventMessage;
    flag = ServerConfig.flag;
    adminOnly = ServerConfig.adminOnly;
    maxCharacters = ServerConfig.maxCharacters;

    ByteBuffer.setUseDirectBuffers(false);
    ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

    acceptor = new SocketAcceptor();
    final SocketAcceptorConfig cfg = new SocketAcceptorConfig();
    cfg.getSessionConfig().setTcpNoDelay(true);
    cfg.setDisconnectOnUnbind(true);
    cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory()));

    try {
        InetSocketadd = new InetSocketAddress(PORT);
        acceptor.bind(InetSocketadd, new MapleServerHandler(), cfg);
        System.out.println(" Complete!");
        System.out.println("Login Server is listening on port " + PORT + ".");
    } catch (IOException e) {
        System.out.println(" Failed!");
        System.err.println("Could not bind to port " + PORT + ": " + e);
    }
}
 
开发者ID:skorch37,项目名称:Asteria,代码行数:29,代码来源:LoginServer.java

示例10: startup

import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public void startup() throws Exception {
    acceptor = new SocketAcceptor();
    TextLineCodecFactory codecFactory = new TextLineCodecFactory(Charset.forName("UTF-8"), LineDelimiter.UNIX);
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(codecFactory));
    acceptor.bind(new InetSocketAddress("127.0.0.1", port), new ServerHandler());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:MinaClientModeTcpTextlineDelimiterTest.java


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