private void dataRec(IAsyncResult ar)
{
int i = 0;
try
{
i = c.Client.EndReceive(ar);
}
catch
{
return;
}
if (i > 0)
{
for (int j = 0; j < i; j++)
{
if (buffer[j] == 10)
{
if (POP3command != null)
{
string line = Encoding.UTF8.GetString(lastLine, 0, linePos - 1).Trim();
linePos = 0;
if (line.Contains(" "))
{
POP3command(this,
line.ToUpper().Substring(0,line.IndexOf(' ')),
line.Substring(line.IndexOf(' ')+1).Split(' '),
line);
}
else
{
POP3command(this,line.ToUpper(), new string[]{}, line);
}
}
}
else
{
lastLine[linePos++] = buffer[j];
if (linePos >= lastLine.Length)
{
err("Make Lines shorter you stupid!", true);
linePos = 0;
if (POP3dropped != null)
{
POP3dropped();
}
return;
}
}
}
if (IsConnected)
{
c.Client.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(dataRec), null);
}
}
}