private void RegisterWithServer()
{
try
{
string command = "CONN|" ChatOut.Text;
Byte[] outbytes = System.Text.Encoding.ASCII.GetBytes(command.ToCharArray());
ns.Write(outbytes,0,outbytes.Length);
string serverresponse = sr.ReadLine();
serverresponse.Trim();
string[] tokens = serverresponse.Split(new Char[]{'|'});
if(tokens[0] == "LIST")
{
statusBar1.Text = "已连接";
btnDisconnect.Enabled = true;
}
for(int n=1; n
lbChatters.Items.Add(tokens[n].Trim(new char[]{'\r','\n'}));
this.Text = clientname ":已连接到服务器";
}
catch (Exception)
{
MessageBox.Show("注册时发生错误!","错误",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}