Package info.walnutstreet.vs.ps03v2.server

Source Code of info.walnutstreet.vs.ps03v2.server.Server

/**
*
*/
package info.walnutstreet.vs.ps03v2.server;

import info.walnutstreet.vs.ps03v2.server.handler.ClientHandler;

import java.net.ServerSocket;
import java.net.Socket;

import org.apache.log4j.Logger;

/**
* @author Christoph Gostner
* @version 0.4
*/
public class Server {
 
  /**
   * Logging ...
   */
  private static Logger logger = Logger.getLogger(Server.class);
 
  /**
   * Start the application server here.
   *
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
   
    try {
      int port = Integer.parseInt(args[0]);
     
      ServerSocket serverSocket = new ServerSocket(port);
      Server.logger.debug("Application-Server started on port " + port);
      while (true) {
        Socket socket = serverSocket.accept();
        ClientHandler handler = new ClientHandler(socket);
        handler.start();
      }
    } catch (NumberFormatException e) {
      Server.logger.error("Please specify a valid port!");
    }
  }
}
TOP

Related Classes of info.walnutstreet.vs.ps03v2.server.Server

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.