本文整理汇总了C#中Socket.EndSendTo方法的典型用法代码示例。如果您正苦于以下问题:C# Socket.EndSendTo方法的具体用法?C# Socket.EndSendTo怎么用?C# Socket.EndSendTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Socket
的用法示例。
在下文中一共展示了Socket.EndSendTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DualModeBeginSendTo_EndPointToHost_Helper
private void DualModeBeginSendTo_EndPointToHost_Helper(IPAddress connectTo, IPAddress listenOn, bool dualModeServer, bool expectedToTimeout = false)
{
int port;
Socket client = new Socket(SocketType.Dgram, ProtocolType.Udp);
using (SocketUdpServer server = new SocketUdpServer(_log, listenOn, dualModeServer, out port))
{
// Send a few packets, in case they aren't delivered reliably.
for (int i = 0; i < Configuration.UDPRedundancy; i++)
{
IAsyncResult async = client.BeginSendTo(new byte[1], 0, 1, SocketFlags.None, new IPEndPoint(connectTo, port), null, null);
int sent = client.EndSendTo(async);
Assert.Equal(1, sent);
}
bool success = server.WaitHandle.WaitOne(expectedToTimeout ? Configuration.FailingTestTimeout : Configuration.PassingTestTimeout); // Make sure the bytes were received
if (!success)
{
throw new TimeoutException();
}
}
}
示例2: DualModeBeginSendTo_EndPointToHost_Helper
private void DualModeBeginSendTo_EndPointToHost_Helper(IPAddress connectTo, IPAddress listenOn, bool dualModeServer)
{
int port;
Socket client = new Socket(SocketType.Dgram, ProtocolType.Udp);
using (SocketUdpServer server = new SocketUdpServer(listenOn, dualModeServer, out port))
{
IAsyncResult async = client.BeginSendTo(new byte[1], 0, 1, SocketFlags.None, new IPEndPoint(connectTo, port), null, null);
int sent = client.EndSendTo(async);
Assert.Equal(1, sent);
bool success = server.WaitHandle.WaitOne(100); // Make sure the bytes were received
if (!success)
{
throw new TimeoutException();
}
}
}