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


Java ServerSocketFactory.createServerSocket方法代码示例

本文整理汇总了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();
	} 
    }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:26,代码来源:GssServer.java

示例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;
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:34,代码来源:GridFTPServerFacade.java

示例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;

}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:36,代码来源:FTPServerFacade.java


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