示例#1
0
 public ReceiveEventArgs(Socket socket, ArrayList sockets)
 {
     this.socket = socket;
     this.clients = sockets;
     this.reader = new Reader(this.socket);
     this.writer = new Writer(this.socket);
 }
示例#2
0
 public void Close()
 {
     this.isConnected = false;
     if (this.writer != null)
     {
         this.writer.Close();
         this.writer = null;
     }
     if (this.reader != null)
     {
         this.reader.Close();
         this.reader = null;
     }
     if (this.thread != null)
     {
         this.thread.Abort();
     }
     if (this.client != null)
     {
         this.client.Shutdown(SocketShutdown.Both);
         this.client.Close();
         this.client = null;
     }
 }
示例#3
0
 public void Connect()
 {
     this.client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     this.client.Connect(new IPEndPoint(IPAddress.Parse(this.hostAddress), this.port));
     this.isConnected = true;
     this.reader = new Reader(this.client);
     this.writer = new Writer(this.client);
     if (this.OnReceive != null)
     {
         this.thread = new Thread(new ThreadStart(this.ReceiveData));
         this.thread.Name = "接收数据";
         this.thread.Start();
     }
 }
示例#4
0
 public ClientThread(Server server, Socket client)
 {
     this.server = server;
     this.socket = client;
     this.writer = new Writer(this.socket);
 }