博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
消息测试
阅读量:4705 次
发布时间:2019-06-10

本文共 691 字,大约阅读时间需要 2 分钟。

    //服务器端

            int port = 1433;

            string host = "10.252.21.8";

 

 

            IPAddress ip = IPAddress.Parse(host);

            IPEndPoint ipe = new IPEndPoint(ip, port);

 

            Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            clientSocket.Connect(ipe);

 

            //send message

            string sendStr = "send to server : hello,ni hao";

            byte[] sendBytes = Encoding.ASCII.GetBytes(sendStr);

            clientSocket.Send(sendBytes);

 

            //receive message

            string recStr = "";

            byte[] recBytes = new byte[4096];

            int bytes = clientSocket.Receive(recBytes, recBytes.Length, 0);

            recStr += Encoding.ASCII.GetString(recBytes, 0, bytes);

 

            textBox2.Text=recStr;

            clientSocket.Close();

转载于:https://www.cnblogs.com/3xin/p/8287066.html

你可能感兴趣的文章
用纯JS实现双向数据绑定
查看>>
php 解决返回数据 数字 变成科学计数法后转换问题
查看>>
How-To-Secure-A-Linux-Server
查看>>
网络与多线程的设计例子
查看>>
ubuntu12.04 各种小问题及解决方案集锦【持续更新】
查看>>
如何更改silverlight datagrid header的背景
查看>>
Data Structure Binary Tree: Construct Full Binary Tree from given preorder and postorder traversals
查看>>
类和对象的系统函数和运算符
查看>>
Checkstyle
查看>>
go语言的数组
查看>>
【题解】士兵训练-C++
查看>>
C#设计模式(4)——抽象工厂模式
查看>>
高级基础知识 ObservableCollection 类
查看>>
20165101刘天野 2018-2019-2《网络对抗技术》Exp5 MSF基础应用
查看>>
LeetCode: Find Bottom Left Tree Value
查看>>
安装包签名
查看>>
流行的开源软件和技术
查看>>
iOS---去除url中的反斜扛
查看>>
qwq
查看>>
检测设备朝向和移动
查看>>