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


Java ServerSocketFactory.getDefault方法代码示例

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


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

示例1: initialize

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
 * Initialize this socket connection. This includes
 * connecting to the host (or listening for it).
 *
 * @throws TransportException if a transport-related error occurs
 */
public void initialize ()
  throws TransportException
{
  try
    {
      if (_server)
        {
          // Get a server socket
          ServerSocketFactory ssf = ServerSocketFactory.getDefault ();
          ServerSocket ss = ssf.createServerSocket (_port, 1);
          _socket = ss.accept ();
        }
      else
        {
          // Get a client socket (the factory will connect it)
          SocketFactory sf = SocketFactory.getDefault ();
          _socket = sf.createSocket (_host, _port);
        }
    }
  catch (IOException ioe)
    {
      // This will grab UnknownHostException, too.
      throw new TransportException (ioe);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:32,代码来源:SocketTransport.java

示例2: initialize

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
  * Initialize this socket connection. This includes
  * connecting to the host (or listening for it).
  *
  * @throws TransportException if a transport-related error occurs
  */
 public void initialize ()
   throws TransportException
 {
   try
     {
if (_server)
  {
    // Get a server socket
    ServerSocketFactory ssf = ServerSocketFactory.getDefault ();
    ServerSocket ss = ssf.createServerSocket (_port, 1);
    _socket = ss.accept ();
  }
else
  {
    // Get a client socket (the factory will connect it)
    SocketFactory sf = SocketFactory.getDefault ();
    _socket = sf.createSocket (_host, _port);
  }
     }
   catch (IOException ioe)
     {
// This will grab UnknownHostException, too.
throw new TransportException (ioe);
     }
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:32,代码来源:SocketTransport.java

示例3: main

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  ServerSocketFactory socketFactory = ServerSocketFactory.getDefault();
  ServerSocket serverSocket = null;
  try {
    serverSocket = socketFactory.createServerSocket(SERVER_PORT);

    listenAndRespond(serverSocket);

  } catch (IOException e) {
    System.out.printf("Socket Failure: %s", e.getMessage());
  } finally {
    if (serverSocket != null) {
      serverSocket.close();
    }
  }
}
 
开发者ID:TripwireInc,项目名称:interview-take-home-test,代码行数:17,代码来源:Server.java

示例4: exportService

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
protected void exportService()
	throws Exception {

	// export
	// create a stream server if needed
	if (streamServer==null) {

		// make sure we have a factory
		if (serverSocketFactory==null) {
			serverSocketFactory = ServerSocketFactory.getDefault();
		}

		// create server socket
		ServerSocket serverSocket = serverSocketFactory
			.createServerSocket(port, backlog, InetAddress.getByName(hostName));

		// create the stream server
		streamServer = new StreamServer(getJsonRpcServer(), maxThreads, serverSocket);
		streamServer.setMaxClientErrors(maxClientErrors);
	}

	// start it
	streamServer.start();
}
 
开发者ID:esz,项目名称:jsonrpc,代码行数:28,代码来源:CompositeJsonStreamServiceExporter.java

示例5: exportService

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void exportService()
	throws Exception {

	// create a stream server if needed
	if (streamServer==null) {

		// make sure we have a factory
		if (serverSocketFactory==null) {
			serverSocketFactory = ServerSocketFactory.getDefault();
		}

		// create server socket
		ServerSocket serverSocket = serverSocketFactory
			.createServerSocket(port, backlog, InetAddress.getByName(hostName));

		// create the stream server
		streamServer = new StreamServer(getJsonRpcServer(), maxThreads, serverSocket);
		streamServer.setMaxClientErrors(maxClientErrors);
	}

	// start it
	streamServer.start();
}
 
开发者ID:esz,项目名称:jsonrpc,代码行数:28,代码来源:JsonStreamServiceExporter.java

示例6: runServer

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
private static void runServer(int port, LocalSunXacml pdp, int threads) {
	Executor clientExec = Executors.newFixedThreadPool(threads);
	ServerSocketFactory sockFac = ServerSocketFactory.getDefault();


	try {
		ServerSocket sock = sockFac.createServerSocket(port);
		while (true) {
			Socket clientSock = sock.accept();
			Runnable cmd = new HandleXacmlRequest(clientSock, pdp);
			System.out.println(nameDate() + "new client " + clientSock.getInetAddress());
			clientExec.execute(cmd);
		}
	} catch (IOException e) {
		System.err.println(nameDate() + e.toString());
		System.exit(1);
	}
}
 
开发者ID:trustathsh,项目名称:irond,代码行数:19,代码来源:RemotePDP.java

示例7: createServerSocket

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
 * Create the right kind of server socket
 */

private ServerSocket createServerSocket()
	throws IOException
{
	if (hostAddress == null)
		hostAddress = InetAddress.getByName(hostArg);
	// Make a list of valid
	// InetAddresses for NetworkServerControl
	// admin commands.
	buildLocalAddressList(hostAddress);
										
	// Create the right kind of socket
	switch (getSSLMode()) {
	case SSL_OFF:
	default:
		ServerSocketFactory sf =
			ServerSocketFactory.getDefault();
		return sf.createServerSocket(portNumber
									 ,0,
									 hostAddress);
	case SSL_BASIC:
		SSLServerSocketFactory ssf =
			(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
		return (SSLServerSocket)ssf.createServerSocket(portNumber,
													   0,
													   hostAddress);
	case SSL_PEER_AUTHENTICATION:
		SSLServerSocketFactory ssf2 =
			(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
		SSLServerSocket sss2= 
			(SSLServerSocket)ssf2.createServerSocket(portNumber,
													 0,
													 hostAddress);
		sss2.setNeedClientAuth(true);
		return sss2;
	}
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:41,代码来源:NetworkServerControlImpl.java

示例8: getServerSocketFactory

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
 * Get the server socket factory from the underlying SSL context.
 * @return Server socket factory
 */
public ServerSocketFactory getServerSocketFactory() { 
    if (ConditionalCompilationControls.TESTHARNESS) {
        if (ConditionalCompilationControls.cleartext)
            return ServerSocketFactory.getDefault();
    }
    return context.getServerSocketFactory(); 
}
 
开发者ID:DamianJMurphy,项目名称:SpineTools-Java,代码行数:12,代码来源:SpineSecurityContext.java

示例9: ConnectServer

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
* Starts the listening server on the defined port.
* @param port the port for the communication with state control
* @throws IOException
*/
   private void ConnectServer(int port) throws IOException{
   	stopServer();
       try {
       	ServerSocketFactory serverSocketFactory = ServerSocketFactory.getDefault();
       	openIGTServer = serverSocketFactory.createServerSocket(this.port);
       	openIGTServer.setReuseAddress(true);
       	System.out.println("State machine interface server Socket succesfully created (port " + this.port + ")");
       } catch (IOException e) {
       	System.out.println("Could not Connect to port :" + this.port + ")");
               throw e;
       }
   }
 
开发者ID:tauscherSw,项目名称:LWROpenIGTIF,代码行数:18,代码来源:LWRStateMachineInterface.java

示例10: ConnectServer

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
    * Starts the listening server on the defined port.
    * @param port the port for the communication with state control
    * @throws IOException
    */
private void ConnectServer(int port) throws IOException{
   	stopServer();
       try {
       	ServerSocketFactory serverSocketFactory = ServerSocketFactory.getDefault();
       	openIGTServer = serverSocketFactory.createServerSocket(this.port);
       	openIGTServer.setReuseAddress(true);
       	System.out.println("Visualization interface server socket succesfully created (port " + this.port + ")");
         
       } catch (IOException e) {
       	System.out.println("Could not Connect to Visualization interface server");
               throw e;
       }
   }
 
开发者ID:tauscherSw,项目名称:LWROpenIGTIF,代码行数:19,代码来源:LWRVisualizationInterface.java

示例11: getSocketFactory

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
private synchronized ServerSocketFactory getSocketFactory()
{
    if (socketFactory == null)
    	socketFactory = ServerSocketFactory.getDefault();
    
    return socketFactory;
}
 
开发者ID:timewalker74,项目名称:ffmq,代码行数:8,代码来源:JMXOverRMIServerSocketFactory.java

示例12: MonitoringServer

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
    * Return statistics about the GSN server, faking an HTTP server for retro-compatibility
    * 
    * the protocol is similar to the carbon protocol used by Graphite, except the timestamp
    * http://matt.aimonetti.net/posts/2013/06/26/practical-guide-to-graphite-monitoring/
    */
public MonitoringServer(int port) {
	super("Monitoring Server");

	try {
		ServerSocketFactory serverSocketFactory = ServerSocketFactory.getDefault();
           socket = serverSocketFactory.createServerSocket(port);
           socket.setSoTimeout(1000);
	}catch(Exception e){
		logger.error("unable to open socket for monitoring",e);
	}
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:18,代码来源:MonitoringServer.java

示例13: main

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
  String serverName = "Deep Thought";
  String configFile = "config";
  ServerSocketFactory serverSockets = ServerSocketFactory.getDefault();
  SocketIOWrapperFactory socketWrappers = SocketIOWrapperFactory.getDefault();

  WebServer server = WebServer.createWebServer(serverName, configFile, serverSockets, socketWrappers);
  GUIWebServer gui = new GUIWebServer(server);
  gui.start();
  try {
    gui.awaitTermination();
  } catch (Exception e) {
  }
}
 
开发者ID:lorandszakacs,项目名称:UPT-Projects,代码行数:18,代码来源:Main.java

示例14: exportService

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void exportService() throws Exception {
	if (streamServer == null) {
		if (serverSocketFactory == null) {
			serverSocketFactory = ServerSocketFactory.getDefault();
		}
		ServerSocket serverSocket = serverSocketFactory.createServerSocket(port, backlog, InetAddress.getByName(hostName));
		streamServer = new StreamServer(getJsonRpcServer(), maxThreads, serverSocket);
		streamServer.setMaxClientErrors(maxClientErrors);
	}
	streamServer.start();
}
 
开发者ID:briandilley,项目名称:jsonrpc4j,代码行数:16,代码来源:CompositeJsonStreamServiceExporter.java

示例15: exportService

import javax.net.ServerSocketFactory; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void exportService() throws Exception {

    if (streamServer == null) {
        if (serverSocketFactory == null) {
            serverSocketFactory = ServerSocketFactory.getDefault();
        }
        ServerSocket serverSocket =
                serverSocketFactory.createServerSocket(port, backlog, InetAddress.getByName(hostName));
        streamServer = new StreamServer(getJsonRpcServer(), maxThreads, serverSocket);
        streamServer.setMaxClientErrors(maxClientErrors);
    }
    streamServer.start();
}
 
开发者ID:briandilley,项目名称:jsonrpc4j,代码行数:18,代码来源:JsonStreamServiceExporter.java


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