- 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.binWebGate
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine(" >------------------------------------------<");
- Console.WriteLine(" >------------------------------------------<");
- Console.WriteLine(" > 列表中文搜索引擎_组件v0.6 <");
- Console.WriteLine(" > Web接口 <");
- 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_web.InitConfigData(k_c_path);
- int Set_Port = XunLong.CongifData.Config_web.WebPort;
- string pathc = XunLong.CongifData.Config_web.WebSite;
- string Set_IP = XunLong.CongifData.Config_web.WebIP;
- Console.WriteLine("端口: " + Set_Port.ToString());
- Console.WriteLine("文件路径: " + pathc);
- Console.WriteLine("绑定IP: " + Set_IP);
- /// <summary>
- /// 帮定的地址 不含 http://
- /// </summary>
- IPAddress myIP;
- IPEndPoint iep;
- try
- {
- myIP = IPAddress.Parse(Set_IP);
- iep = new IPEndPoint(myIP, Set_Port);
- }
- catch
- {
- Console.WriteLine("你输入的服务器名或端口号格式不正确,请重新输入!");
- return;
- }
- XF:
- //定义端口号
- TcpListener tcplistener = new TcpListener(iep);
- tcplistener.Start();
- //记录总的访问次数
- int v = 0;
- //侦听端口号
- while (true)
- {
- try
- {
- Socket socket = tcplistener.AcceptSocket();
- //并获取传送和接收数据的Scoket实例
- ServerXLClass CWebServer_one = new ServerXLClass(socket);
- //类实例化
- Thread T = new Thread(new ThreadStart(CWebServer_one.Run));
- //创建线程
- T.Start();
- //启动线程
- v = v + 1;
- Console.WriteLine("ALL-NUM-Web-GATE:"+ v.ToString() +" Time:" + DateTime.Now.ToString() );
- }
- catch
- {
- goto XF;
- }
- }
- }
- }
- }