本文整理汇总了C#中System.Net.Sockets.SocketFlags枚举的典型用法代码示例。如果您正苦于以下问题:C# SocketFlags枚举的具体用法?C# SocketFlags怎么用?C# SocketFlags使用的例子?那么恭喜您, 这里精选的枚举代码示例或许可以为您提供帮助。
在下文中一共展示了SocketFlags枚举的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendReceiveTest3
// Displays sending with a connected socket
// using the overload that takes a buffer, message size, and socket flags.
public static int SendReceiveTest3(Socket server)
{
byte[] msg = Encoding.UTF8.GetBytes("This is a test");
byte[] bytes = new byte[256];
try
{
// Blocks until send returns.
int i = server.Send(msg, msg.Length, SocketFlags.None);
Console.WriteLine("Sent {0} bytes.", i);
// Get reply from the server.
int byteCount = server.Receive(bytes, server.Available,
SocketFlags.None);
if (byteCount > 0)
Console.WriteLine(Encoding.UTF8.GetString(bytes));
}
catch (SocketException e)
{
Console.WriteLine("{0} Error code: {1}.", e.Message, e.ErrorCode);
return (e.ErrorCode);
}
return 0;
}