當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。