zhiyue大侠
我整个工程运行起来的时候
要什么时候运行,比如我下面的代码
Socket socket = srvSocket.accept();就死在那边了
我这段代码要什么时候运行?
public static void main(String args[]) throws IOException
{
//GeServerSocket serverSocket=null;
GeProperties prop=null;
ServerSocket srvSocket=null;
String hostname=null;
String configFile=null;
int port;
String IP;
String ServerID;
//Socket socket=null;
GeExecutionMgr executionMgr=null;
GeQueueMgr queueMgr=null;
//if (args.length != 1)
//{
// System.out.println("Usage: java StartServer configfile");
// System.exit(0);
//}
//configFile = args[0];
configFile="c:/ServerConfig.txt";
prop = new GeProperties(configFile);
try {
// start the server socket, listening on some port
//port = prop.getPropertyInt(GeConstants.ServerPort, 7000);
port = prop.getPropertyInt("7000", 7000);
srvSocket = new ServerSocket(7000, 200);
IP=prop.getProperty(GeConstants.IP);
//ServerID=IP+":"+port;
ServerID="127.0.0.1"+":"+port;
GeSessionRegistery.sessions.startSession(ServerID,prop);
System.out.println("SERVER DEBUG: Starting FrontEnd Server Listening On : "+port);
int status=DbManager.InitDBPool(prop);
Log.initLog(prop.getProperty(GeConstants.LOG_FILE));
//Log.initLog(prop.getProperty("c:/server.log"));
}
catch (Exception e)
{ // quit if we can not start the server socket
e.printStackTrace();
System.exit(0);
}
while (true)
{
try {
// accept socket request
Socket socket = srvSocket.accept();
System.out.println("SERVER DEBUG: Accepting Socket Connection From Web Server!");
System.out.println("SERVER DEBUG: Starting Working ThreadPool and Waiting for Request!");
//init reqeust and response Queue Manager;
queueMgr=new GeQueueMgr();
//start thread pooling;
executionMgr=new GeExecutionMgr(prop,queueMgr, GeWnCommandFactory.commandFactory);
// spawn a slave socket to each new connection
GeServerSocket serverSocket = new GeServerSocket(socket,queueMgr);
}
catch (Exception e)
{
e.printStackTrace();
return;
}
}
}