Program.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:3k
源码类别:

搜索引擎

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Threading;
  5. using System.Net;
  6. using System.Net.Sockets;
  7. using System.IO;
  8. /*
  9.       '       迅龙中文分类搜索引擎  v0.6
  10.       '
  11.       '        LGPL  许可发行
  12.       '
  13.       '       宁夏大学  张冬 康彩  zd4004@163.com
  14.       ' 
  15.       '        官网 http://blog.163.com/zd4004/
  16.  */
  17. namespace XunLong.binWebGate
  18. {
  19.     class Program
  20.     {
  21.         static void Main(string[] args)
  22.         {
  23.             Console.WriteLine("  >------------------------------------------<");
  24.             Console.WriteLine("  >------------------------------------------<");
  25.             Console.WriteLine("  >          列表中文搜索引擎_组件v0.6       <");
  26.             Console.WriteLine("  >                  Web接口                 <");
  27.             Console.WriteLine("  >------------------------------------------<");
  28.             Console.WriteLine("  >------------------------------------------<");
  29.             Console.WriteLine("=============================================");
  30.             Console.WriteLine("=                                           =");
  31.             Console.WriteLine("迅龙Web  ===接口=== 服务器");
  32.             Console.WriteLine("=   根据主类别判断需要调用的服务器          =");
  33.             Console.WriteLine("=============================================");
  34.             //读取配置
  35.             string k_c_path = args[0];
  36.             Console.WriteLine("--》Web服务器_加载配置文件: " + k_c_path);
  37.             XunLong.CongifData.Config_web.InitConfigData(k_c_path); 
  38.             int Set_Port = XunLong.CongifData.Config_web.WebPort;
  39.             string pathc = XunLong.CongifData.Config_web.WebSite;
  40.             string Set_IP = XunLong.CongifData.Config_web.WebIP;
  41.             Console.WriteLine("端口: " + Set_Port.ToString());
  42.             Console.WriteLine("文件路径: " + pathc);
  43.             Console.WriteLine("绑定IP: " + Set_IP);
  44.             /// <summary>
  45.             /// 帮定的地址 不含 http://
  46.             /// </summary>
  47.           
  48.             IPAddress myIP;
  49.             IPEndPoint iep;
  50.             try
  51.             {
  52.                 myIP = IPAddress.Parse(Set_IP);
  53.                 iep = new IPEndPoint(myIP, Set_Port);
  54.             }
  55.             catch
  56.             {
  57.                 Console.WriteLine("你输入的服务器名或端口号格式不正确,请重新输入!");
  58.                 return;
  59.             }
  60.         XF:
  61.             //定义端口号
  62.             TcpListener tcplistener = new TcpListener(iep);
  63.          
  64.             tcplistener.Start();
  65.             //记录总的访问次数
  66.             int v = 0;
  67.             //侦听端口号
  68.             while (true)
  69.             {
  70.                 try
  71.                 {
  72.                     Socket socket = tcplistener.AcceptSocket();
  73.                     //并获取传送和接收数据的Scoket实例
  74.                     ServerXLClass CWebServer_one = new ServerXLClass(socket);
  75.                     //类实例化
  76.                     Thread T = new Thread(new ThreadStart(CWebServer_one.Run));
  77.                    
  78.                     //创建线程
  79.                     T.Start();
  80.                     //启动线程
  81.                     v = v + 1;
  82.                     Console.WriteLine("ALL-NUM-Web-GATE:"+ v.ToString() +"   Time:" + DateTime.Now.ToString() );
  83.                 }
  84.                 catch
  85.                 {
  86.                     goto XF;
  87.                 }
  88.             }
  89.         }
  90.     }
  91. }