本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
示例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);
}
示例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);
}
}
示例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));
}
示例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);
}
}
示例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());
}