I have a basic socket server that looks like this:
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 8000);
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
newsock.Bind(localEndPoint);
}
catch (Exception e)
{
//Errors handled
}
newsock.Listen(10);
Console.WriteLine("Bound to port 8000");
Socket client = newsock.Accept();
while (client.Connected)
{
Console.WriteLine("Connection recieved.");
string outputString = null;
byte[] buffer = new byte[4];
client.Receive(buffer);
string bit = null;
while (bit != "\r\n" || bit != "\n" || bit != "\r")
{
bit = Encoding.ASCII.GetString(buffer);
outputString += bit;
}
Console.WriteLine(outputString);
}
Right now I want it to accept input until the user (telnet currently) sends an EOL (presses enter) the code above is mostly what I've tried thus far, how should I be doing this?