internal void PrintNew()
{
//1.创建Socket对象
Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress ip = IPAddress.Parse("xxx.xxx.x.xxx");
//2.绑定IP和端口
IPEndPoint endpoint = new IPEndPoint(ip, int.Parse("6000"));
try
{
//这里客户端套接字连接到网络节点(服务端)用的方法是Connect 而不是Bind
clientSocket.Connect(endpoint);
//MessageBox.Show("ip连接成功...");
}
catch
{
MessageBox.Show("与系统连接失败,请检查计算机以及系统(新)!");
}
int[] selectRows = gridView1.GetSelectedRows();//获取当前列表行数
if (selectRows != null && selectRows.Length > 0)
{
StringBuilder builder = new StringBuilder();
foreach (var row in selectRows)
{
if (this.gridView1.GetRowCellValue
C# 使用Socket对接
最新推荐文章于 2025-04-08 23:27:53 发布