本文整理汇总了C#中MemBlock.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# MemBlock.GetBytes方法的具体用法?C# MemBlock.GetBytes怎么用?C# MemBlock.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemBlock
的用法示例。
在下文中一共展示了MemBlock.GetBytes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Free
/// <summary>
/// 释放
/// </summary>
/// <param name="block"></param>
public void Free(MemBlock block)
{
if (block.GetBytes() == null)
return;
int nIndex = GetIndex(block.GetMaxLength());
if (nIndex >= mMaxList)
return;
mAllMemList[nIndex].Enqueue(block);
}
示例2: SendData
/// <summary>
/// 发送消息
/// </summary>
/// <param name="data"></param>
protected void SendData(MemBlock data)
{
// 连接了之后才能发送
if (!mIsConnected)
return;
try
{
mIsSending = true;
IAsyncResult iar = mSocket.BeginSend(data.GetBytes(), 0, data.UseSize, SocketFlags.None, new AsyncCallback(SendDataCallBack), data);
}
catch (SocketException ex)
{
string strError = ex.ToString();
Logger.GetLog("NetCommon").Error(strError);
}
catch (Exception ex)
{
string strError = ex.ToString();
Logger.GetLog("NetCommon").Error(strError);
}
}
示例3: SendMessage
/// <summary>
/// 发送数据
/// </summary>
/// <param name="byData"></param>
/// <param name="length"></param>
/// <param name="offset"></param>
public void SendMessage(byte[] byData, int length, int offset)
{
mWriteMem = mPool.Alloc(length);
Buffer.BlockCopy(byData, offset, mWriteMem.GetBytes(), 0, length);
// 可以结束了
SetProcessDone(true);
}
示例4: Process
/// <summary>
/// 具体的处理逻辑
/// </summary>
protected override void Process()
{
try
{
Stream stream = mContext.Request.InputStream;
mReadMem = mPool.Alloc((int)stream.Length);
stream.Read(mReadMem.GetBytes(), 0, (int)stream.Length);
mHttpServer.ReceiveData(this, mReadMem.GetBytes(), mReadMem.UseSize);
}
catch(Exception ex)
{
Logger.GetLog("NetCommon").Error("Http Message Read Error:Process");
Logger.GetLog("NetCommon").Error(ex.ToString());
}
}
示例5: PushMessage
/// <summary>
/// 添加到发送队列
/// </summary>
/// <param name="block"></param>
protected void PushMessage(MemBlock block)
{
lock(mSendLock)
{
if (block.GetBytes() == null)
return;
mSendQueue.Enqueue(block);
}
}
示例6: PushSendData
/// <summary>
/// 添加到发送队列,以后定时检查,超时重发
/// </summary>
/// <param name="block"></param>
/// <param name="ipEndPoint"></param>
/// <param name="sendEvent"></param>
protected void PushSendData(MemBlock block, IPEndPoint ipEndPoint)
{
SendData sendData = new SendData();
sendData.EndPoint = ipEndPoint;
sendData.EnterTime = Environment.TickCount;
sendData.Packet = block;
sendData.UUID = BitConverter.ToInt64(block.GetBytes(), 0);
PushSend(sendData);
}
示例7: SendMessage
/// <summary>
/// 发送消息
/// </summary>
/// <param name="block"></param>
/// <param name="ipEndPoint"></param>
public virtual void SendMessage(MemBlock block, IPEndPoint ipEndPoint)
{
try
{
// 已经Connect过的连接不能发送到远程端口
if (mRemote == null)
mUdpClient.Send(block.GetBytes(), block.UseSize, ipEndPoint);
else
mUdpClient.Send(block.GetBytes(), block.UseSize);
}
catch(SocketException ex)
{
// 发送失败,一般是网络连接出错
if( ex.SocketErrorCode == SocketError.InvalidArgument )
{
Logger.GetLog("NetCommon").Error("Net Link Error, Check Network Card Start Or Network Link Is OK!");
}
}
catch(Exception ex)
{
Logger.GetLog("NetCommon").Error(ex.ToString());
}
}