首页 新闻 会员 周边 捐助

Unity Exception.Message为空串是怎么回事?

0
悬赏园豆:20 [已关闭问题] 关闭于 2021-08-07 22:49

最近在unity中实现接受屏幕分享的功能。昨天程序还运行得好好的,不知道今天怎么不停捕捉到错误,但捕捉到的错误又没有提示,所以请教一下各位大佬们。

private void ReceiveCallback(IAsyncResult result)
{
    int read = client.EndReceive(result);
    //Debug.Log(read);
    try
    {
        if (read > 0)
        {
            if (data == null)
            {
                dataLength = BitConverter.ToInt32(buffer, 4);
                currentLength = 0;
                data = new byte[dataLength];
                Array.ConstrainedCopy(buffer, 4, data, currentLength, read - 4);
                currentLength = read - 4;
            }
            else
            {
                int rest = dataLength - currentLength;
                if (rest < read)
                    read = rest;
                Array.ConstrainedCopy(buffer, 0, data, currentLength, read);
                currentLength += read;
                if (currentLength >= dataLength&& !dataHandle.IsFull())
                {
                    dataHandle.SaveByteArray(data);                   
                    data = null;
                }
            }
        }
        else
        {
            client.Shutdown(SocketShutdown.Both);
            client.Close();
        }
    }
    catch (Exception e)
    {
        Debug.Log(e.Message);
        client.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, ReceiveCallback, null);
    }
    client.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, ReceiveCallback, null);
}

mshentai的主页 mshentai | 菜鸟二级 | 园豆:202
提问于:2021-08-07 22:32
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册