日期:2014-05-17 浏览次数:21022 次
public void Receive(IAsyncResult iar)//接收数据的方法
{
//try
//{
String DateString = string.Empty;
ObjectSocket os = (ObjectSocket)iar.AsyncState;
Socket handler = os.worksocket;
int Read = handler.EndReceive(iar);
DateString = Encoding.ASCII.GetString(os.BufferDate, 0, ObjectSocket.BufferSize);
if (DateString.Contains("HEADEND"))
{
int headlleght = Encoding.ASCII.GetBytes(Search_string(DateString, "HEADSTART", "HEADEND")).Length + Encoding.ASCII.GetBytes("HEADSTART").Length + Encoding.ASCII.GetBytes("HEADEND").Length;
DateAnalysis(Search_string(DateString, "HEADSTART", "HEADEND"), headlleght, os);
}
os.worksocket.BeginReceive(os.BufferDate, 0, ObjectSocket.BufferSize, 0,
new AsyncCallback(Receive), os);//接收完后回调该方法 等待下一次数据接收
//}
//catch (Exception e)
//{
//}
}