C#下Socket对象的BeginReceive方法,执行后竟然不调用AsyncCallback里的回调函数 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

   

    到底是怎么回事?仅仅发生在我的机器上,修改了ip配置后放到别的机器上是没有任何问题的,可以很好的回调,

C#下Socket对象的BeginReceive方法,执行后竟然不调用AsyncCallback里的回调函数

。难道我的机器有何异常?请教高手了!

    某一线程下socket对象user.sock开始执行BeginReceive语句:

    user.sock.BeginReceive(user.buffer,0,User.BufferSize,0,new System.AsyncCallback(DoRecevive),user);

    对应的回调函数:

    public static void DoRecevive(IAsyncResult ar)

    {

    Console.WriteLine("Begin Receive Date, Waiting for the Call Back");

    //...

    }

    在我的机器上BeginReceive之后不执行DoRecevive函数,在别的机器上可以很好的执行该函数并且

    打出“Begin Receive Date, Waiting for the Call Back”字符串

最新文章