예제 #1
0
파일: LoginForm.cs 프로젝트: anggia81/OOP
        private void OnConnect(IAsyncResult ar)
        {
            try
            {
                clientSocket.EndConnect(ar);

                //We are connected so we login into the server
                Data msgToSend = new Data ();
                msgToSend.cmdCommand = Command.Login;
                msgToSend.strName = txtName.Text;
                msgToSend.strMessage = null;

                string message = "test";
                byte[] b = msgToSend.ToByte ();
                //byte[] b = Convert.ToByte(message);
                List<byte> result = new List<byte>();
                result.AddRange(BitConverter.GetBytes(message.Length));
                byte[] c = result.ToArray();

                //Send the message to the server
                clientSocket.BeginSend(b, 0, b.Length, SocketFlags.None, new AsyncCallback(OnSend), null);
                //clientSocket.BeginSend(c, 0, c.Length, SocketFlags.None, new AsyncCallback(OnSend), null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ChatClient", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
파일: ChatClient.cs 프로젝트: anggia81/OOP
        //Broadcast the message typed by the user to everyone
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                //Fill the info for the message to be send
                Data msgToSend = new Data();

                msgToSend.strName = strName;
                msgToSend.strMessage = txtMessage.Text;
                msgToSend.cmdCommand = Command.Message;

                byte [] byteData = msgToSend.ToByte();

                //Send it to the server
                clientSocket.BeginSend (byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnSend), null);

                txtMessage.Text = null;
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to send message to the server.", "ChatClient: " + strName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        private void irc_OnChannelAction(string text, Data ircdata)
        {
            try
            {
                if (!alIgnoredHosts.Contains(irc.GetChannelUser(User.channel, ircdata.Nick).Host))
                {
                    for (int i = 0; i < tabControlChatTabs.TabPages.Count; i++)
                    {
                        if (tabControlChatTabs.TabPages[i].Text.ToString().Equals(User.channel))
                        {
                            AppendText(User.channel, "tag", "[");
                            AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                            AppendText(User.channel, "tag", "] ");
                            AppendText(User.channel, "action", "* " + ircdata.Nick.ToString() + " ");
                            AppendText(User.channel, "action", text);
                            AppendText(User.channel, "text", "\n");
                            User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + "* " + ircdata.Nick.ToString() + " " + text + "\n");

                            alPrivMsgAlert.Add(i);
                            break;
                        }
                    }

                    tabControlChatTabs.Refresh();
                }
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #4
0
        private void irc_OnBan(string str1, string str2, string str3, Data ircdata)
        {
            try
            {
                AppendText(User.channel, "tag", "[");
                AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                AppendText(User.channel, "tag", "] ");
                AppendText(User.channel, "notice", " -!- " + ircdata.Nick.ToString() + " has banned " + str3.ToString() + "\n");

                User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + ircdata.Nick.ToString() + " has banned " + str3.ToString() + "\n");
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #5
0
        private void OnQueryMessage_DelegateFunction(Data ircdata)
        {
            try
            {
                if (!alIgnoredHosts.Contains(irc.GetChannelUser(User.channel, ircdata.Nick).Host))
                {
                    if (listBoxUserList.Items.Contains(Nickname(ircdata.Nick.ToString())))
                    {
                        tab = new TabPage(ircdata.Nick);

                        if (!alprivMsgs.Contains(ircdata.Nick.ToString()))
                        {
                            textBoxChatWindow = new Khendys.Controls.ExRichTextBox();
                            textBoxChatWindow.BackColor = User.background;
                            textBoxChatWindow.ForeColor = User.text;
                            textBoxChatWindow.ReadOnly = true;
                            textBoxChatWindow.Font = new Font(User.defaultFontFamily, User.defaultFontSize, User.defaultFontStyle, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
                            textBoxChatWindow.Dock = System.Windows.Forms.DockStyle.Fill;
                            textBoxChatWindow.Visible = true;

                            tab.Controls.Add(textBoxChatWindow);

                            alprivMsgs.Add(ircdata.Nick.ToString());

                            alPrivMsgWindows = new ArrayList();
                            alPrivMsgWindows.Add(textBoxChatWindow);

                            alPrivMsgWindowList.Add(alPrivMsgWindows);

                            string nickname = ircdata.Nick;
                            AppendText(tab.Text, "tag", "[");
                            AppendText(tab.Text, "time", DateTime.Now.ToShortTimeString().ToString());
                            AppendText(tab.Text, "tag", "] ");
                            AppendText(tab.Text, "notice", " -!- " + nickname + " is " +
                                irc.GetChannelUser(User.channel, nickname).Ident.ToString() + "@" +
                                irc.GetChannelUser(User.channel, nickname).Host.ToString() + " (" +
                                irc.GetChannelUser(User.channel, nickname).Realname.ToString() + ")\n");

                            addTabPageDelegate = new AddTabPage_Delegate(AddTabPage_DelegateFunction);
                            IAsyncResult r = BeginInvoke(addTabPageDelegate, new object[] { tab });
                            EndInvoke(r);

                            OnQueryMessage_DelegateFunction(ircdata);
                        }
                        else
                        {
                            for (int i = 0; i < tabControlChatTabs.TabPages.Count; i++)
                            {
                                if (tabControlChatTabs.TabPages[i].Text.ToString().Equals(ircdata.Nick.ToString()))
                                {
                                    tab = tabControlChatTabs.TabPages[i];
                                    AppendText(tab.Text, "tag", "[");
                                    AppendText(tab.Text, "time", DateTime.Now.ToShortTimeString().ToString());
                                    AppendText(tab.Text, "tag", "] <");
                                    AppendText(tab.Text, "person", Nickname(ircdata.Nick.ToString()));
                                    AppendText(tab.Text, "tag", "> ");
                                    AppendText(tab.Text, "person", ircdata.Message.ToString());
                                    AppendText(tab.Text, "text", "\n");
                                    User.Log(tab.Text, "[" + DateTime.Now.ToShortTimeString().ToString() + "] <" + ircdata.Nick.ToString() + "> " + ircdata.Message.ToString() + "\n");

                                    alPrivMsgAlert.Add(i);
                                }
                            }

                            tabControlChatTabs.Refresh();

                            for (int i = 0; i < tab.Controls.Count; i++)
                            {
                                if (tab.Controls[i].GetType().Name == "ExRichTextBox")
                                {
                                    AppendText(tab.Controls[i].Text, "tag", "[");
                                    AppendText(tab.Controls[i].Text, "time", DateTime.Now.ToShortTimeString().ToString());
                                    AppendText(tab.Controls[i].Text, "tag", "] <");
                                    AppendText(tab.Controls[i].Text, "person", ircdata.Nick.ToString());
                                    AppendText(tab.Controls[i].Text, "tag", "> ");
                                    AppendText(tab.Controls[i].Text, "person", ircdata.Message.ToString());
                                    AppendText(tab.Controls[i].Text, "text", "\n");
                                    User.Log(tab.Controls[i].Text, "[" + DateTime.Now.ToShortTimeString().ToString() + "] <" + ircdata.Nick.ToString() + "> " + ircdata.Message.ToString() + "\n");
                                }
                            }
                        }

                        ShowChatWindow();
                    }
                }
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #6
0
 private void irc_OnWho(string str1, string str2, string str3, string str4, string str5, bool bl1, bool bl2, bool bl3, bool bl4, bool bl5, bool bl6, bool bl7, string str6, int i, Data ircdata)
 {
 }
예제 #7
0
파일: ChatClient.cs 프로젝트: anggia81/OOP
        private void OnReceive(IAsyncResult ar)
        {
            try
            {
                clientSocket.EndReceive(ar);

                Data msgReceived = new Data(byteData);
                //Accordingly process the message received
                switch (msgReceived.cmdCommand)
                {
                    case Command.Login:
                        lstChatters.Items.Add(msgReceived.strName);
                        break;

                    case Command.Logout:
                        lstChatters.Items.Remove(msgReceived.strName);
                        break;

                    case Command.Message:
                        break;

                    case Command.List:
                        lstChatters.Items.AddRange(msgReceived.strMessage.Split('*'));
                        lstChatters.Items.RemoveAt(lstChatters.Items.Count - 1);
                        txtChatBox.Text += "<<<" + strName + " has joined the room>>>\r\n";
                        break;
                }

                if (msgReceived.strMessage != null && msgReceived.cmdCommand != Command.List)
                    txtChatBox.Text += msgReceived.strMessage + "\r\n";

                byteData = new byte[1024];

                clientSocket.BeginReceive(byteData,
                                          0,
                                          byteData.Length,
                                          SocketFlags.None,
                                          new AsyncCallback(OnReceive),
                                          null);

            }
            catch (ObjectDisposedException)
            { }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ChatClient: " + strName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #8
0
        private void Register_Click(object sender, EventArgs e)
        {
            var regObj = Data.CreateRegister(GenerateRegisterData());

            this._comptroller.PaketQueue.Enqueue(regObj);
        }
예제 #9
0
        private void irc_OnJoin(string str1, string str2, Data ircdata)
        {
            try
            {
                if (!ircdata.Nick.ToString().Equals(irc.Nickname.ToString()))
                {
                    AppendText(User.channel, "tag", "[");
                    AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                    AppendText(User.channel, "tag", "] ");
                    AppendText(User.channel, "notice", " -!- " + ircdata.Nick.ToString() + " [" + ircdata.Ident.ToString() + "@" + ircdata.Host.ToString() + "] has joined " + str1.ToString() + "\n");
                    User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + ircdata.Nick.ToString() + " [" + ircdata.Ident.ToString() + "@" + ircdata.Host.ToString() + "] has joined " + str1.ToString() + "\n");
                }
                else
                {
                    if (mblnShowWelcomeMessage)
                    {
                        AppendText(User.channel, "notice", "-------------------------------------" + "\n");
                        AppendText(User.channel, "notice", " -!- You're in! You can start chatting now. ");
                        AppendText(User.channel, "text", "\n");

                        AppendText(User.channel, "notice", " -!- You may want to change your default nickname.");
                        AppendText(User.channel, "text", "\n");

                        AppendText(User.channel, "notice", " -!- Enter \"/nick random12345\" (without quotes) to change your nickname to random12345.");
                        AppendText(User.channel, "text", "\n");

                        mblnShowWelcomeMessage = false;
                    }

                    AppendText(User.channel, "tag", "[");
                    AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                    AppendText(User.channel, "tag", "] ");
                    AppendText(User.channel, "notice", " -!- " + irc.Nickname.ToString() + " [" + ircdata.Ident.ToString() + "@" + ircdata.Host.ToString() + "] has joined " + str1.ToString() + "\n");

                    User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + irc.Nickname.ToString() + " [" + ircdata.Ident.ToString() + "@" + ircdata.Host.ToString() + "] has joined " + str1.ToString() + "\n");
                    allowInput = true;
                }

                if (!ircdata.Nick.ToString().Equals(irc.Nickname.ToString()))
                {
                    AddUserToUserList(ircdata.Nick.ToString());
                }
                else
                {
                    AddUserToUserList(irc.Nickname.ToString());
                }
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #10
0
        private void irc_OnQuit(string str1, string str2, Data ircdata)
        {
            try
            {
                if (str2 != null)
                {
                    AppendText(User.channel, "tag", "[");
                    AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                    AppendText(User.channel, "tag", "] ");
                    AppendText(User.channel, "notice", " -!- " + ircdata.Nick.ToString() + " [" + ircdata.Ident + "@" + ircdata.Host + "] has quit" + " (" + str2.ToString() + ")" + "\n");
                    User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + ircdata.Nick.ToString() + " [" + ircdata.Ident + "@" + ircdata.Host + "] has quit" + " (" + str2.ToString() + ")" + "\n");
                }
                else
                {
                    AppendText(User.channel, "tag", "[");
                    AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                    AppendText(User.channel, "tag", "] ");
                    AppendText(User.channel, "notice", " -!- " + ircdata.Nick.ToString() + " [" + ircdata.Ident + "@" + ircdata.Host + "] has quit\n");
                    User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + ircdata.Nick.ToString() + " [" + ircdata.Ident + "@" + ircdata.Host + "] has quit\n");
                }

                if (alprivMsgs.Contains(ircdata.Nick.ToString()))
                {
                    for (int i = 0; i < tabControlChatTabs.TabPages.Count; i++)
                    {
                        if (tabControlChatTabs.TabPages[i].Text.ToString().Equals(ircdata.Nick.ToString()))
                        {
                            removeTabPageDelegate = new RemoveTabPage_Delegate(RemoveTabPage_DelegateFunction);
                            IAsyncResult r = BeginInvoke(removeTabPageDelegate, new object[] { tabControlChatTabs.TabPages[i] });
                            EndInvoke(r);
                        }
                    }
                }

                RemoveUserFromUserList(ircdata.Nick.ToString());
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #11
0
        private void irc_OnQueryNotice(Data ircdata)
        {
            try
            {
                if (ircdata.Nick != null)
                {
                    AppendText(tabControlChatTabs.SelectedTab.Text, "tag", "[");
                    AppendText(tabControlChatTabs.SelectedTab.Text, "time", DateTime.Now.ToShortTimeString().ToString());
                    AppendText(tabControlChatTabs.SelectedTab.Text, "tag", "] ");
                    AppendText(tabControlChatTabs.SelectedTab.Text, "notice", " -!- " + ircdata.Nick.ToString() + " - " + ircdata.Message.ToString() + "\n");

                    User.Log(tabControlChatTabs.SelectedTab.Text, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + ircdata.Nick.ToString() + " - " + ircdata.Message.ToString() + "\n");
                }
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #12
0
 private void irc_OnQueryMessage(Data ircdata)
 {
     try
     {
         if (ircdata.Nick != null)
         {
             onQueryMessageDelegate = new OnQueryMessage_Delegate(OnQueryMessage_DelegateFunction);
             IAsyncResult r = BeginInvoke(onQueryMessageDelegate, new object[] { ircdata });
             EndInvoke(r);
         }
     }
     catch (Exception ex)
     {
         User.ErrorLog(ex.ToString());
     }
 }
예제 #13
0
        private void irc_OnNickChange(string str1, string str2, Data ircdata)
        {
            try
            {
                this.Text = Application.Name + " [" + User.server + ":" + User.port.ToString() + ", " + irc.Nickname + "] - " + irc.GetChannel(User.channel).Topic.ToString();

                AppendText(User.channel, "tag", "[");
                AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                AppendText(User.channel, "tag", "] ");
                AppendText(User.channel, "notice", " -!- " + str1.ToString() + " is now known as " + str2.ToString() + "\n");

                User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + str1.ToString() + " is now known as " + str2.ToString() + "\n");

                for (int i = 0; i < alprivMsgs.Count; i++)
                {
                    if (alprivMsgs[i].ToString().Equals(str1))
                    {
                        alprivMsgs[i] = str2;
                    }
                }

                for (int i = 0; i < tabControlChatTabs.TabPages.Count; i++)
                {
                    if (tabControlChatTabs.TabPages[i].Text.ToString().Equals(str1))
                    {
                        tabControlChatTabs.TabPages[i].Text = str2;
                    }
                }

                UpdateUserList(true);
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #14
0
        private void irc_OnKick(string str1, string str2, string str3, string str4, Data ircdata)
        {
            try
            {
                AppendText(User.channel, "tag", "[");
                AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                AppendText(User.channel, "tag", "] ");
                AppendText(User.channel, "notice", " -!- " + str2.ToString() + " was kicked from " + str1.ToString() + " by " + ircdata.Nick.ToString() + " (" + str4.ToString() + ")" + "\n");

                User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + str2.ToString() + " was kicked from " + str1.ToString() + " by " + ircdata.Nick.ToString() + " (" + str4.ToString() + ")" + "\n");

                RemoveUserFromUserList(str2.ToString());

                if (str2.Equals(User.username))
                {
                    irc.Join(User.channel);
                }
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #15
0
파일: ChatClient.cs 프로젝트: anggia81/OOP
        private void SGSClient_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to leave the chat room?", "SGSclient: " + strName,
                MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
            {
                e.Cancel = true;
                return;
            }

            try
            {
                //Send a message to logout of the server
                Data msgToSend = new Data ();
                msgToSend.cmdCommand = Command.Logout;
                msgToSend.strName = strName;
                msgToSend.strMessage = null;

                byte[] b = msgToSend.ToByte ();
                clientSocket.Send(b, 0, b.Length, SocketFlags.None);
                clientSocket.Close();
            }
            catch (ObjectDisposedException)
            { }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ChatClient: " + strName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #16
0
        private void irc_OnChannelMessage(Data ircdata)
        {
            try
            {
                if (tabControlChatTabs.InvokeRequired)
                {
                    tabControlChatTabs.Invoke(new OnChannelMessage_Delegate(irc_OnChannelMessage), new object[] { ircdata });
                }
                else
                {
                    if (!alIgnoredHosts.Contains(irc.GetChannelUser(User.channel, ircdata.Nick).Host))
                    {
                        for (int i = 0; i < tabControlChatTabs.TabPages.Count; i++)
                        {
                            if (tabControlChatTabs.TabPages[i].Text.ToString().Equals(User.channel))
                            {
                                AppendText(User.channel, "tag", "[");
                                AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                                AppendText(User.channel, "tag", "] <");
                                AppendText(User.channel, "person", Nickname(ircdata.Nick.ToString()));
                                AppendText(User.channel, "tag", "> ");
                                AppendText(User.channel, "text", ircdata.Message.ToString());
                                AppendText(User.channel, "text", "\n");

                                User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] <" + ircdata.Nick.ToString() + "> " + ircdata.Message.ToString() + "\n");

                                alPrivMsgAlert.Add(i);

                                break;
                            }
                        }

                        tabControlChatTabs.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #17
0
        private void irc_OnHalfOp(string str1, string str2, string str3, Data ircdata)
        {
            try
            {
                AppendText(User.channel, "tag", "[");
                AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                AppendText(User.channel, "tag", "] ");
                AppendText(User.channel, "notice", " -!- " + ircdata.Nick.ToString() + " has given halfop status to " + str3.ToString() + " on " + str1.ToString() + "\n");

                User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + ircdata.Nick.ToString() + " has given halfop status to " + str3.ToString() + " on " + str1.ToString() + "\n");
                UpdateUserList(true);
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #18
0
 private void irc_OnTopic(string str1, string str2, Data ircdata)
 {
     try
     {
         if (this.InvokeRequired)
         {
             this.Invoke(new OnTopic_Delegate(irc_OnTopic), new object[] { str1, str2, ircdata });
         }
         else
         {
             this.Text = Application.Name + " [" + User.server + ":" + User.port.ToString() + ", " + irc.Nickname + "] - " + irc.GetChannel(User.channel).Topic.ToString();
         }
     }
     catch (Exception ex)
     {
         User.ErrorLog(ex.ToString());
     }
 }
예제 #19
0
 private void irc_OnUserModeChange(Data ircdata)
 {
 }
예제 #20
0
        private void irc_OnVoice(string str1, string str2, string str3, Data ircdata)
        {
            try
            {
                if (irc.GetChannelUser(User.channel, str3).IsOp)
                {
                    irc.Deop(User.channel, str3);
                }

                if (irc.GetChannelUser(User.channel, str3).IsOwner)
                {
                    irc.DeOwner(User.channel, str3);
                }

                if (irc.GetChannelUser(User.channel, str3).IsHalfOp)
                {
                    irc.DeHalfOp(User.channel, str3);
                }

                AppendText(User.channel, "tag", "[");
                AppendText(User.channel, "time", DateTime.Now.ToShortTimeString().ToString());
                AppendText(User.channel, "tag", "] ");
                AppendText(User.channel, "notice", " -!- " + ircdata.Nick.ToString() + " has given voice status to " + str3.ToString() + " on " + str1.ToString() + "\n");

                User.Log(User.channel, "[" + DateTime.Now.ToShortTimeString().ToString() + "] " + " -!- " + ircdata.Nick.ToString() + " has given voice status to " + str3.ToString() + " on " + str1.ToString() + "\n");
                UpdateUserList(true);
            }
            catch (Exception ex)
            {
                User.ErrorLog(ex.ToString());
            }
        }
예제 #21
0
 public Data GetLoginPaket()
 {
     return(Data.CreateLogin(GenerateLoginData()));
 }
예제 #22
0
파일: ChatClient.cs 프로젝트: anggia81/OOP
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "ChatClient: " + strName;

            //The user has logged into the system so we now request the server to send
            //the names of all users who are in the chat room
            Data msgToSend = new Data ();
            msgToSend.cmdCommand = Command.List;
            msgToSend.strName = strName;
            msgToSend.strMessage = null;

            byteData = msgToSend.ToByte();

            clientSocket.BeginSend(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnSend), null);

            byteData = new byte[1024];
            //Start listening to the data asynchronously
            clientSocket.BeginReceive(byteData,
                                       0,
                                       byteData.Length,
                                       SocketFlags.None,
                                       new AsyncCallback(OnReceive),
                                       null);
        }