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

搜索引擎

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Net;
  5. using System.Net.Sockets;
  6. using System.Text;
  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.NewXWord
  18. {
  19.     class NewLinkClass
  20.     {
  21.         Encoding gbx = System.Text.Encoding.GetEncoding("gb2312");
  22.         Socket clientSocket;
  23.         string Set_Path;
  24.         public NewLinkClass(Socket socket)
  25.         {
  26.             this.clientSocket = socket;
  27.         }
  28.         public void Run()
  29.         {
  30.             Byte[] read = new byte[2048];
  31.             try
  32.             {
  33.                 while (true)
  34.                 {
  35.                     //存放解析出地址请求信息
  36.                     int bytes = clientSocket.Receive(read, 2048, 0);
  37.                     if (bytes == 0)
  38.                     {
  39.                         clientSocket.Close();
  40.                         return;
  41.                     }
  42.             
  43.                     string str = gbx.GetString(read, 0, bytes);
  44.                     string bk = ClassCMD.GetOne(str);
  45.                     byte[] message =gbx.GetBytes(bk);
  46.                     clientSocket.Send(message);
  47.                 }
  48.             }
  49.             catch
  50.             {
  51.                 try
  52.                 { clientSocket.Close(); }
  53.                 catch
  54.                 { }
  55.             }
  56.         }
  57.     }
  58. }
  59.