- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading;
- using System.Net;
- using System.Net.Sockets;
- using System.IO;
- /*
- ' 迅龙中文分类搜索引擎 v0.6
- '
- ' LGPL 许可发行
- '
- ' 宁夏大学 张冬 康彩 zd4004@163.com
- '
- ' 官网 http://blog.163.com/zd4004/
- */
- namespace XunLong.NewWebServer
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine(" >------------------------------------------<");
- Console.WriteLine(" >------------------------------------------<");
- Console.WriteLine(" > 列表中文搜索引擎_组件v0.6 <");
- Console.WriteLine(" > Web Server <");
- Console.WriteLine(" >------------------------------------------<");
- Console.WriteLine(" >------------------------------------------<");
- Console.WriteLine("=============================================");
- Console.WriteLine("= =");
- Console.WriteLine("迅龙Web服务器");
- Console.WriteLine("= =");
- Console.WriteLine("=============================================");
- //读取配置
- string k_c_path = args[0];
- Console.WriteLine("--》Web服务器_加载配置文件: " + k_c_path);
- XunLong.CongifData.Config.InitConfigData(k_c_path);
- int Set_Port = XunLong.CongifData.Config.WebPort;
- string pathc = XunLong.CongifData.Config.WebSite;
- string Set_IP = XunLong.CongifData.Config.WebIP;
- /// <summary>
- /// 帮定的地址 不含 http://
- /// </summary>
- string HTTPURL =XunLong.CongifData.Config.WebIP+":"+XunLong.CongifData.Config.WebPort.ToString();
- IPAddress myIP;
- IPEndPoint iep;
- try
- {
- myIP = IPAddress.Parse(Set_IP);
- iep = new IPEndPoint(myIP, Set_Port);
- }
- catch
- {
- Console.WriteLine("你输入的服务器名或端口号格式不正确,请重新输入!");
- return;
- }
- XF:
- ClassRUN_XZ.Init(k_c_path);
- ClassRUN_XZ.SetHTTPURL(HTTPURL);
- //定义端口号
- TcpListener tcplistener = new TcpListener(iep);
- Console.WriteLine("侦听端口号: " + Set_Port.ToString());
- tcplistener.Start();
- Console.WriteLine("绑定地址: "+ HTTPURL);
- //侦听端口号
- while (true)
- {
- try
- {
- Socket socket = tcplistener.AcceptSocket();
- //并获取传送和接收数据的Scoket实例
- CWebServer CWebServer_one = new CWebServer(socket, pathc);
- //类实例化
- Thread T = new Thread(new ThreadStart(CWebServer_one.Run));
- //创建线程
- T.Start();
- //启动线程
- }
- catch
- {
- goto XF;
- }
- }
- }
- }
- }