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


Java ServerSocketChannel.bind方法代码示例

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


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

示例1: listen

import java.nio.channels.ServerSocketChannel; //导入方法依赖的package包/类
public SA listen(NioThread nt, SocketAddress address, byte[] thisId, byte[] otherId) throws Exception
{
	ServerSocketChannel ssc=ServerSocketChannel.open();
	ssc.configureBlocking(false);
	ssc.bind(address);
	SA sa=new SA(nt, ssc, thisId, otherId);
	sa.start();
	return sa;
}
 
开发者ID:rizsi,项目名称:rcom,代码行数:10,代码来源:CoolRMINioServer.java

示例2: run

import java.nio.channels.ServerSocketChannel; //导入方法依赖的package包/类
private void run() throws Exception
{
	NioThread nt=new NioThread();
	nt.start();
	Thread.sleep(1000);
	ServerSocketChannel ssc=ServerSocketChannel.open();
	ssc.configureBlocking(false);
	ssc.bind(new InetSocketAddress("localhost", 9999));
	RMINioConnectionServer niosrv=new RMINioConnectionServer();
	RMISocketAcceptor sa=new RMISocketAcceptor(nt, ssc, niosrv);
	sa.start();
	CoolRMIServer srv=new CoolRMIServer(getClass().getClassLoader(), new RMINioConnectionServerFactory(niosrv), false);
	srv.getServiceRegistry().addService(new CoolRMIService(Iremote.class.getName(), Iremote.class, new Remote()));
	srv.start();
}
 
开发者ID:rizsi,项目名称:rcom,代码行数:16,代码来源:RMINioServer.java

示例3: run

import java.nio.channels.ServerSocketChannel; //导入方法依赖的package包/类
private void run() throws Exception
{
	NioThread nt=new NioThread();
	nt.start();
	Thread.sleep(1000);
	ServerSocketChannel ssc=ServerSocketChannel.open();
	ssc.configureBlocking(false);
	ssc.bind(new InetSocketAddress("localhost", 9999));
	SocketAcceptor sa=new SocketAcceptor(nt, ssc);
	sa.start();
}
 
开发者ID:rizsi,项目名称:rcom,代码行数:12,代码来源:ExampleNioServer.java

示例4: openForProject

import java.nio.channels.ServerSocketChannel; //导入方法依赖的package包/类
/**
 * Registers the connection and initiates the listening socket.
 * @param project the project which is being run / debugged
 * @param debugger if true, the connection will pair with a debugger session.
 */
public ShellAgent openForProject(Project p, boolean debugger) throws IOException {
    ServerSocket ss;
    
    String encodedKey;
    boolean shouldInit = false;
    
    synchronized (this) {
        shouldInit = usedKeys.isEmpty();
        do {
            BigInteger key = BigInteger.probablePrime(64, keyGenerator);
            encodedKey = key.toString(Character.MAX_RADIX);
        } while (!usedKeys.add(encodedKey));
    }
    
    if (shouldInit) {
        init();
    }
    
    ServerSocketChannel ssc = ServerSocketChannel.open();
    ssc.configureBlocking(false);
    SocketAddress local = new InetSocketAddress(
        // PENDING: choose something better for remote debugging!
        InetAddress.getLoopbackAddress(),
        0);
    ssc.bind(local);
    ssc.accept();
    ss = ssc.socket();
    LOG.log(Level.FINE, "Creating new server socket {0} for project: {1}", new Object[] {
        ss, p
    });
    ShellAgent agent = new ShellAgent(this, p, ss, encodedKey, debugger);
    synchronized (this) {
        registeredAgents.put(encodedKey, agent);
    }
    synchronized (requests) {
        servers.wakeup();
        requests.add(agent);
        
    }
    return agent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:ShellLaunchManager.java


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