本文整理汇总了Java中org.globus.net.ServerSocketFactory.createServerSocket方法的典型用法代码示例。如果您正苦于以下问题:Java ServerSocketFactory.createServerSocket方法的具体用法?Java ServerSocketFactory.createServerSocket怎么用?Java ServerSocketFactory.createServerSocket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.globus.net.ServerSocketFactory
的用法示例。
在下文中一共展示了ServerSocketFactory.createServerSocket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.globus.net.ServerSocketFactory; //导入方法依赖的package包/类
public static void main(String [] args) {
String usage = "Usage: java GssServer [options] [port]";
GetOpts opts = new GetOpts(usage, helpMsg);
int pos = opts.parse(args);
int port = 0;
if (pos < args.length) {
port = Integer.parseInt(args[pos]);
}
ServerSocketFactory factory = ServerSocketFactory.getDefault();
try {
ServerSocket server = factory.createServerSocket(port);
System.out.println("Server running at: " + server.getLocalPort());
while(true) {
Client c = new Client(server.accept(), opts);
c.start();
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: setStripedPassive
import org.globus.net.ServerSocketFactory; //导入方法依赖的package包/类
public HostPortList setStripedPassive(int port, int queue)
throws IOException {
// remove existing sockets, if any
socketPool.flush();
if (serverSocket == null) {
ServerSocketFactory factory =
ServerSocketFactory.getDefault();
serverSocket = factory.createServerSocket(port, queue);
}
gSession.serverMode = GridFTPSession.SERVER_EPAS;
gSession.serverAddressList = new HostPortList();
String address = Util.getLocalHostAddress();
int localPort = serverSocket.getLocalPort();
HostPort hp = null;
if (remoteControlChannel.isIPv6()) {
String version = HostPort6.getIPAddressVersion(address);
hp = new HostPort6(version, address, localPort);
} else {
hp = new HostPort(address, localPort);
}
gSession.serverAddressList.add(hp);
logger.debug("started single striped passive server at port " +
((HostPort) gSession.serverAddressList.get(0)).getPort());
return gSession.serverAddressList;
}
示例3: setPassive
import org.globus.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
Start the local server
@param port required server port; can be set to ANY_PORT
@param queue max size of queue of awaiting new connection
requests
@return the server address
**/
public HostPort setPassive(int port, int queue)
throws IOException{
if (serverSocket == null) {
ServerSocketFactory factory =
ServerSocketFactory.getDefault();
serverSocket = factory.createServerSocket(port, queue);
}
session.serverMode = Session.SERVER_PASSIVE;
String address = Util.getLocalHostAddress();
int localPort = serverSocket.getLocalPort();
if (remoteControlChannel.isIPv6()) {
String version = HostPort6.getIPAddressVersion(address);
session.serverAddress =
new HostPort6(version, address, localPort);
} else {
session.serverAddress =
new HostPort(address, localPort);
}
logger.debug("started passive server at port " +
session.serverAddress.getPort());
return session.serverAddress;
}