private int SendBuffer(NetBuffer buffer, bool isReSend) { //进行加密 if (m_Cryptor != null) { if (!isReSend) { m_Cryptor.Encrypt(buffer.GetBytes(), buffer.Length); } } //写入CheckSum if (m_UseCheckSum_Send) { if (isReSend) { FSPCryptor.ModifyCheckSum(buffer); } else { FSPCryptor.AddCheckSum(buffer); } } if (FSPDebuger.EnableLog) { Debuger.Log(LOG_TAG_RECV, "SendBuffer() Size={0}, IP={1}, Buffer={2}", buffer.Length, m_HostEndPoint, buffer.ToHexString()); } int sendCnt = 0; try { sendCnt = m_Socket.SendTo(buffer.GetBytes(), buffer.Length, m_HostEndPoint); } catch (Exception e) { Debuger.LogWarning(LOG_TAG_SEND, "SendBuffer() " + e); } if (sendCnt <= 0) { if (FSPDebuger.EnableLog) { Debuger.LogWarning(LOG_TAG_SEND, "SendBuffer() 数据发送失败, IP={0}, Size={1}", m_HostEndPoint, buffer.Length); } } return(sendCnt); }
private void SendMessageIfSocketNotDisposed(byte[] messageData, UdpEndPoint destination) { var socket = _SendSocket; if (socket != null) { _SendSocket.SendTo(messageData, destination); } else { ThrowIfDisposed(); } }