I have this bit of code that is receiving a series of messages:
byte[] buffer = new byte[10240];
//...
sock.Receive(buffer);
string response = message(buffer);
Console.WriteLine("Message Recieved");
if (!verifyUser(response, sock))
Console.WriteLine("User Invalid");
//...
static private bool verifyUser(string userString, Socket sock)
{
string[] userData = userString.Split(' ');
int i = 0;
while (true)
{
if (userData[0].ToUpper() != "USER")
{
byte[] buffer = message("WHO");
sock.Send(buffer);
userData = userString.Split(' ');
i++;
if (i > 4)
{
return false;
}
continue;
}
else
break;
}
Console.WriteLine("Connection recieved from " + userData[1] + " with hash of "/* + userData[2]*/);
}
The problem I'm having is that if I submit the username unkwntech all that gets displayed it unkwnt, and the second value never seems to get there. the app sending the data looks like this:
static void Main(string[] args)
{
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
EndPoint remoteEP = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 200);
sock.Connect(remoteEP);
byte[] buffer = Encoding.ASCII.GetBytes("USER unkwntech a3f5h4a35sfg");//Made up hash
sock.Send(buffer);
sock.Receive(buffer);
Console.WriteLine(Encoding.ASCII.GetString(buffer));
Console.ReadLine();
}