C# socket ipv6初体验
2024-09-03 04:58:41
Server:
serverSocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
serverSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
if (!string.IsNullOrEmpty(SocketBindingIP))
{
serverSocket.Bind(new IPEndPoint(IPAddress.IPv6Any, int.Parse(Program.config.AppSettings.Settings["Middleware_PORT"].Value)));
lbWebApiBaseAddress.Text = ip;
LogMessage(DateTime.Now + "->Socket开启IPV6监听成功,监听IP:" + IPAddress.IPv6Any.ToString() + ":" + Program.config.AppSettings.Settings["Middleware_PORT"].Value);
}
else
{
serverSocket.Bind(new IPEndPoint(IPAddress.Parse(ip), int.Parse(Program.config.AppSettings.Settings["Middleware_PORT"].Value)));
lbWebApiBaseAddress.Text = IPAddress.Parse(ip).ToString();
LogMessage(DateTime.Now + "->Socket开启IPV6监听成功,监听IP:" + IPAddress.Parse(ip) + ":" + Program.config.AppSettings.Settings["Middleware_PORT"].Value);
}
client:
m_clientSocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
m_clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
EndPoint ipeh_Server = new IPEndPoint(IPAddress.Parse(textBox1.Text), Convert.ToInt32(textBox2.Text));
if (!m_clientSocket.IsBound)
{
if (comboBox1.Text == "自动分配")
{
m_clientSocket.Bind(new IPEndPoint(IPAddress.IPv6Any, 0));
}
else
{
m_clientSocket.Bind(new IPEndPoint(IPAddress.IPv6Any, Convert.ToInt32(comboBox1.Text)));
}
}
最新文章
- Flume(2)组件概述与列表
- iOS UIAlertView添加输入框
- Memcached Java Client API详解
- B.xml
- 【转】成为it精英,我奋斗7年
- Spring实战——无需一行xml配置实现自动化注入
- bzoj 1604 [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居(set+并查集)
- res://ieframe.dll/acr_error.htm 纯手动解决方法
- linux下创建可引导的U盘系统,使用dd命令进行Linux的ghost
- [js高手之路]深入浅出webpack教程系列8-(postcss-loader,autoprefixer,html-loader,less-loader,ejs-loader)用法
- docker基本原理
- js精度误差
- 微信h5支付demo微信H5支付demo非微信浏览器支付demo微信wap支付
- php页面开启错误提示
- cmd如何进入d盘
- JS两种事件的触发方式
- Python-统计svn变更代码行数
- NodeJs实现客户端登陆
- appium===浮窗无法定位的解决办法
- JQ自定义下拉列表插件
热门文章
- 使用Redis作为Spring Security OAuth2的token存储
- Dockerfile 中的 CMD 与 ENTRYPOINT(转)
- Spring-AOP源码分析随手记(二)
- Swagger实例分享(VS+WebApi+Swashbuckle)
- WPF中获取Hwnd与窗体,Uid获取控件
- ASP.NET Core appsettings.json 文件
- 宣布Visual Studio Code Installer for Java
- MVC 创建Controllers 发生 EntityType has no key defined error
- C typedef、#define
- 原生JavaScript HTML DOM Style 对象参考