ClassRunIt.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:2k
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Net;
- using System.Net.Sockets;
- using System.Collections;
- using System.Threading;
- /*
- ' 迅龙中文分类搜索引擎 v0.6
- '
- ' LGPL 许可发行
- '
- ' 宁夏大学 张冬 康彩 zd4004@163.com
- '
- ' 官网 http://blog.163.com/zd4004/
- */
- namespace XunLong.NewXWord
- {
- /// <summary>
- /// 服务数据接入类
- /// </summary>
- class ClassRunIt
- {
-
- /// <summary>
- /// 是否监听
- /// </summary>
- public bool isListen = true;
- public void StartListen()
- {
- IPAddress myIP;
- IPEndPoint iep;
- try
- {
- myIP = IPAddress.Parse(XunLong.CongifData.Config.xWordCacheServer);
- iep = new IPEndPoint(myIP, XunLong.CongifData.Config.xWordCacheServerPort);
- }
- catch
- {
- Console.WriteLine("你输入的服务器名或端口号格式不正确,请重新输入!");
- return;
- }
- Console.WriteLine("开始监听...");
- Console.WriteLine(" 在 " + XunLong.CongifData.Config.xWordCacheServer + " : " + XunLong.CongifData.Config.xWordCacheServerPort.ToString());
- Console.WriteLine("********************************************");
- Console.WriteLine("");
- ClassCMD.Init();
- StartXD:
-
- //定义端口号
- TcpListener tcplistener = new TcpListener(iep);
- tcplistener.Start();
- //侦听端口号
- while (true)
- {
- try
- {
- Socket socket = tcplistener.AcceptSocket();
- socket.ReceiveTimeout = 30000;
- //并获取传送和接收数据的Scoket实例
- NewLinkClass CWebServer_one = new NewLinkClass(socket);
- //类实例化
- Thread TX = new Thread(new ThreadStart(CWebServer_one.Run));
- //创建线程
- TX.Start();
- //启动线程
- }
- catch
- {
- goto StartXD;
- }
- }
- }
- }
- }