Example #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);
 }
Example #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;
     }
 }
Example #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();
     }
 }