Void ListenConnectSocket ()
{
While (isOpen)
{
Try
{
The Socket ClientSocket=serverSocket. The Accept ();
Byte [] buffer=Encoding. The Default. GetBytes (" to connect to the server success!" );
ClientSocket. Send (buffer);
String client=ClientSocket. RemoteEndPoint. ToString ();
ListBox1. Invoke (new Action
{
ListBox1. Items. The Add (DateTime. Now + ":" + MSG);
}), the client);
Thread THR=new Thread (ReceiveCkientMsg);
THR. IsBackground=true;
THR. Start (ClientSocket);
}
The catch (Exception ex)
{
ListenThread. Abort (ex. Message);
}
}
}
CodePudding user response:
With the form, the form of invoke