Exemplo n.º 1
0
    private string SendAll(WfPacket msgSending, ref int nSended)
    {
        SocketError socketError;
        int         sendNum = m_Socket.Send(msgSending.GetReadBytes(), nSended, msgSending.GetOffset() - nSended, SocketFlags.None, out socketError);
        string      result;

        if (sendNum < 0)
        {
            result = "SendData < 0";
        }
        else
        {
            if (socketError != SocketError.Success && socketError != SocketError.WouldBlock)
            {
                result = "SendData Failed";
            }
            else
            {
                nSended += sendNum;
                if (nSended > msgSending.GetOffset())
                {
                    result = "SendData IO error";
                }
                else
                {
                    result = null;
                }
            }
        }
        //Debug.Log("底层函数发送数据给服务器:"+socketError.ToString());
        return(result);
    }