static void Main(string[] args) { Console.Write("~"); string input = Convert.ToString(Console.ReadLine()); if (input == "start") { Console.Write("what port would you like the server to be hosted on?: "); try { port = Convert.ToInt32(Console.ReadLine()); } catch (OverflowException) { Console.WriteLine("What in tarnation! that port is not valid! Try another port."); } catch (FormatException) { Console.WriteLine("That isnt a number, mate. Try again"); } Console.Write("Would you like a password?"); string passStr = Convert.ToString(Console.ReadLine()); passStr = passStr.ToLower(); if (passStr == "yes" || passStr == "y") { Console.Write("Please enter the password you would like for your chatroom: "); string password = (Console.ReadLine()); Console.Write("Confirm? [y/n]"); string dec = Convert.ToString(Console.ReadLine()); dec = dec.ToLower(); if (dec == "y") { Console.Write("Confirmed. Now listening on " + port + " with password"); } else { //not confirmed message } } else { Console.Write("What is the IP of this machine? "); string ipIn = Convert.ToString(Console.ReadLine()); IPAddress ipA = Dns.Resolve(ipIn).AddressList[0]; Console.WriteLine("Now listening on port " + port); TcpListener servSock = new TcpListener(ipA, port); TcpClient clientsock = default(TcpClient); int count = 0; servSock.Start(); while ((true)) { count++; clientsock = servSock.AcceptTcpClient(); byte[] bytesFrom = new byte[10025]; string clientData = null; Random rand0 = new Random(); NetworkStream netstr = clientsock.GetStream(); netstr.Read(bytesFrom, 0, bytesFrom.Length); clientData = Encoding.ASCII.GetString(bytesFrom); clientData = clientData.Substring(0, clientData.IndexOf("$")); CL.Clear(); try { CL.Add(clientData, clientsock); } catch { int temp0 = rand0.Next(0, 1111); string temp1 = Convert.ToString(temp0); clientData = clientData + temp1; CL.Add(clientData, clientsock); } transmit(clientData + " Has Arrived \n", clientData, false); ClientHandler client0 = new ClientHandler(); Console.WriteLine(clientData + " Has Arrived "); client0.ClientStart(clientsock, clientData, CL); } } } }