示例#1
0
    private static string SendAll(DP_Msg data, WfPacket msgSending, ref int nSended)
    {
        SocketError socketError;
        int         num = data.clientSocket.Send(msgSending.GetBytes(), nSended, msgSending.GetOffset() - nSended, SocketFlags.None, out socketError);
        string      result;

        if (num < 0)
        {
            result = "SendData < 0";
        }
        else
        {
            if (socketError != SocketError.Success && socketError != SocketError.WouldBlock)
            {
                result = "SendData Failed";
            }
            else
            {
                nSended += num;
                if (nSended > msgSending.GetOffset())
                {
                    result = "SendData IO error";
                }
                else
                {
                    result = null;
                }
            }
        }
        return(result);
    }
示例#2
0
 public static void SendPacket(ClientSession session, WfPacket packet)
 {
     byte[] data = packet.GetBytes();
     session.Send(data);
 }