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