日期:2014-05-17  浏览次数:21002 次

异常:指定的参数已超出有效值的范围,参数名:size、远程主机强迫关闭了一个现有连接。求大侠们帮帮忙,谢谢!
 //接收数据头
        void ReceiveHeader(System.IAsyncResult ar)
        {
            NetBitStream stream = (NetBitStream)ar.AsyncState;
            try
            {
                int read = stream._socket.EndReceive(ar);
                if (read < 1)
                {
                    PushPacket((ushort)MessageIdentifiers.ID.CONNECTION_LOST,"", stream._socket);
                    return;
                }
                stream.DecodeHeader();
                stream._socket.BeginReceive(stream.BYTES, NetBitStream.header_length, stream.BodyLength, SocketFlags.None, new System.AsyncCallback(ReceiveBody), stream);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);//异常信息:远程主机强迫关闭了一个现有连接
                Console.WriteLine("1333333333333it is here!");//////////////////////////////////////////////////////////////////////////////////////////
                //异常信息:指定的参数已超出有效值的范围,参数名:size
                
                Console.ReadKey();
                PushPacket((ushort)MessageIdentifiers.ID.CONNECTION_LOST, e.Message, stream._socket);

            }
        }
c#???socket c# socket