Esempio n. 1
0
        static public string StartServer()
        {
            // Establish the local endpoint for the socket.
            // Dns.GetHostName returns the name of the
            // host running the application.
            string      hostName   = Dns.GetHostName();
            IPHostEntry ipHostInfo = Dns.Resolve(hostName); // obsolete but it works

            if (CSavedIPs.Subs == "")
            {
                string subs = "";
                foreach (IPAddress i in ipHostInfo.AddressList)
                {
                    if (subs != "")
                    {
                        subs += ",";
                    }
                    string ip  = i.ToString();
                    int    loc = ip.IndexOf('.');
                    loc   = ip.IndexOf('.', loc + 1);
                    loc   = ip.IndexOf('.', loc + 1);
                    subs += ip.Substring(0, loc);
                }
                CSavedIPs.ChangeSubList(subs);
            }

            Task.Factory.StartNew(() => StartListening(ipHostInfo));

            return(CSavedIPs.Subs);
        }
Esempio n. 2
0
 private void buttonGoConnection_Click(object sender, EventArgs e)
 {
     CSavedIPs.ChangeSubList(this.textBoxSubs.Text);
     Sock.SetSock(this.userName, this.myIP, this.textBoxSubs.Text);
     Sock.StartSearching(this);
     appendText(richTextBoxChatOut, "Searching..." + Environment.NewLine, Color.LightGreen);
     this.buttonGoConnection.Enabled = false;
 }
Esempio n. 3
0
        private void Chatter_FormClosing(object sender, FormClosingEventArgs e)
        {
            CSavedIPs.ChangeSubList(this.textBoxSubs.Text);
            this.isExit = true;
            // temp file cleanup
            try
            {
                foreach (string key in linkList.Keys)
                {
                    if (File.Exists(linkList[key]))
                    {
                        File.Delete(linkList[key]);
                    }
                }
            }
            catch
            { }

            Sock.KillTasks();
        }