本文整理汇总了C#中Record.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Record.Send方法的具体用法?C# Record.Send怎么用?C# Record.Send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.Send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendRecord
public void SendRecord(RecordType type, ushort requestID,
byte [] bodyData, int bodyIndex,
int bodyLength)
{
if (IsConnected)
lock (send_lock) {
try {
send_buffers.EnforceBodyLength(bodyLength);
Array.Copy(bodyData, bodyIndex, send_buffers.Body.Value.Array, send_buffers.Body.Value.Offset, bodyLength);
var record = new Record (1, type, requestID, send_buffers, bodyLength);
record.Send (socket);
} catch (System.Net.Sockets.SocketException) {
}
}
}
示例2: EndRequest
public void EndRequest(ushort requestID, int appStatus,
ProtocolStatus protocolStatus)
{
var body = new EndRequestBody (appStatus, protocolStatus);
try {
if (IsConnected) {
byte[] bodyData = body.GetData ();
send_buffers.EnforceBodyLength(bodyData.Length);
Array.Copy(bodyData, 0, send_buffers.Body.Value.Array, send_buffers.Body.Value.Offset, bodyData.Length);
var record = new Record (1, RecordType.EndRequest, requestID, send_buffers, bodyData.Length);
record.Send (socket);
}
} catch (System.Net.Sockets.SocketException) {
}
int index = GetRequestIndex (requestID);
if (index >= 0) {
lock (request_lock) {
requests.RemoveAt (index);
}
}
lock (connection_teardown_lock) {
if (requests.Count == 0 && (!keep_alive || stop)) {
CloseSocket ();
if (!stop)
server.EndConnection (this);
receive_buffers.Return ();
send_buffers.Return ();
}
}
}