本文整理汇总了C#中INode.ToEndPoint方法的典型用法代码示例。如果您正苦于以下问题:C# INode.ToEndPoint方法的具体用法?C# INode.ToEndPoint怎么用?C# INode.ToEndPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.ToEndPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendInternal
protected override void SendInternal(byte[] buffer, int index, int length, INode destination)
{
try
{
if (Client == null || WasDisposed)
{
HeliosTrace.Instance.UdpClientSendFailure();
Close();
return;
}
var buf = Allocator.Buffer(length);
buf.WriteBytes(buffer, index, length);
List<IByteBuf> encodedMessages;
Encoder.Encode(this, buf, out encodedMessages);
foreach (var message in encodedMessages)
{
var bytesToSend = message.ToArray();
var bytesSent = 0;
while (bytesSent < bytesToSend.Length)
{
bytesSent += Client.SendTo(bytesToSend, bytesSent, bytesToSend.Length - bytesSent,
SocketFlags.None, destination.ToEndPoint());
}
HeliosTrace.Instance.UdpClientSend(bytesSent);
HeliosTrace.Instance.UdpClientSendSuccess();
}
}
catch (SocketException ex)
{
HeliosTrace.Instance.UdpClientSendFailure();
Close(ex);
}
catch (Exception ex)
{
HeliosTrace.Instance.UdpClientSendFailure();
InvokeErrorIfNotNull(ex);
}
}
示例2: Send
public override void Send(byte[] buffer, int index, int length, INode destination)
{
var clientSocket = SocketMap[destination];
try
{
if (clientSocket.WasDisposed)
{
CloseConnection(clientSocket);
return;
}
var buf = Allocator.Buffer(length);
buf.WriteBytes(buffer, index, length);
List<IByteBuf> encodedMessages;
Encoder.Encode(ConnectionAdapter, buf, out encodedMessages);
foreach (var message in encodedMessages)
{
var state = CreateNetworkState(clientSocket.Socket, destination, message,0);
clientSocket.Socket.BeginSendTo(message.ToArray(), 0, message.ReadableBytes, SocketFlags.None, destination.ToEndPoint(),
SendCallback, state);
}
}
catch (SocketException ex)
{
CloseConnection(ex, clientSocket);
}
catch (Exception ex)
{
OnErrorIfNotNull(ex, clientSocket);
}
}