本文整理汇总了C#中System.Net.Sockets.UdpClient.EndSend方法的典型用法代码示例。如果您正苦于以下问题:C# UdpClient.EndSend方法的具体用法?C# UdpClient.EndSend怎么用?C# UdpClient.EndSend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Sockets.UdpClient
的用法示例。
在下文中一共展示了UdpClient.EndSend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public void Send()
{
var msg = Encoding.ASCII.GetBytes(Message);
try {
var client = new UdpClient();
client.Client.Bind(new IPEndPoint(LocalAddress, 0));
client.Ttl = 10;
client.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 10);
client.BeginSend(msg, msg.Length, EndPoint, result =>
{
try {
client.EndSend(result);
}
catch (Exception ex) {
_logger.Debug(ex);
}
finally {
try {
client.Close();
}
catch (Exception) {
}
}
}, null);
}
catch (Exception ex) {
_logger.Error(ex);
}
++SendCount;
}
示例2: Send
public void Send()
{
var msg = Encoding.ASCII.GetBytes(Message);
try {
var client = new UdpClient();
client.Client.Bind(new IPEndPoint(LocalAddress, 0));
client.BeginSend(msg, msg.Length, EndPoint, result =>
{
try {
client.EndSend(result);
}
catch (Exception ex) {
Debug(ex);
}
finally {
try {
client.Close();
}
catch (Exception) {
}
}
}, null);
}
catch (Exception ex) {
Error(ex);
}
++SendCount;
}
示例3: Send
public void Send()
{
var msg = Encoding.ASCII.GetBytes(Message);
foreach (var external in IP.ExternalIPAddresses) {
try {
var client = new UdpClient(new IPEndPoint(external, 0));
client.BeginSend(msg, msg.Length, EndPoint, result =>
{
try {
client.EndSend(result);
}
catch (Exception ex) {
Debug(ex);
}
finally {
try {
client.Close();
}
catch (Exception) {
}
}
}, null);
}
catch (Exception ex) {
Error(ex);
}
}
++SendCount;
}