-
C# 指定主机和端口发消息的实现
Visual C# 指定主机和端口发消息的实现例子,支持和远程主机发送消息,本例子可学习到很多实用的网络方法的用法,以下代码是本功能的核心实现:
richTextBox1.Text = string.Empty;
//实例化UdpClient对象
UdpClient udpclient = new UdpClient(Convert.ToInt32(textBox2.Text));
//调用UdpClient对象的Connect建立默认远程主机
udpclient.Connect(textBox1.Text, Convert.ToInt32(textBox2.Text));
//定义一个字节数组,用来存放发送到远程主机的信息
Byte[] sendBytes = Encoding.Default.GetBytes(textBox3.Text);
//调用UdpClient对象的Send方法将Udp数据报发送到远程主机
udpclient.Send(sendBytes, sendBytes.Length);
//实例化IPEndPoint对象,用来显示响应主机的标识
IPEndPoint ipendpoint = new IPEndPoint(IPAddress.Any, 0);
//调用UdpClient对象的Receive方法获得从远程主机返回的Udp数据报
Byte[] receiveBytes = udpclient.Receive(ref ipendpoint);
//将获得的Udp数据报转换为字符串形式
string returnData = Encoding.Default.GetString(receiveBytes);
richTextBox1.Text = "接收到的信息:" + returnData.ToString();
//使用IPEndPoint对象的Address和Port属性获得响应主机的IP地址和端口号
richTextBox1.Text += "
这条信息来自主机" + ipendpoint.Address.ToString()
+ "上的" + ipendpoint.Port.ToString() + "端口";
//关闭UdpClient连接
- 2022-02-10 10:21:19下载
- 积分:1
-
JmailSample
This a one page form example that saves the form results to a text file, then sends an email to the customer and one to the site owner. Very handy. Fully customizable form fields and messages. Good for customer service form(3KB
- 2004-07-08 14:46:57下载
- 积分:1
-
UdpClient-UdpServer
用udp协议通讯示例--包括udp客户端与服务端的源代码。(Examples using udp protocol communications- including the udp client and server source code.)
- 2009-12-27 16:19:00下载
- 积分:1
-
ime-coding
介绍windows输入法编程的书籍 对学习输入法有所帮助(Introduction windows programming books IME input method for learning to help)
- 2013-09-27 11:47:16下载
- 积分:1
-
Bad-TV-Transition-V2.prfpset
Damaged VHS filter for aftereffects
- 2014-09-21 19:56:11下载
- 积分:1
-
新建文件夹 (2)
说明: opencv车道线检测,Canny算子加霍夫变换,卡尔曼滤波(Lane detection of opencv)
- 2019-04-26 12:29:48下载
- 积分:1
-
C# 在LINQ to XML中将XML文件转换为CSV文件的例子源码
C# 在LINQ to XML中将XML文件转换为CSV文件的例子源码,转换的结果请参考如图所示:
private void button1_Click(object sender, EventArgs e)
{//在LINQ to XML中将XML文件转换为CSV文件
TextReader MyReader = new StringReader(this.textBox1.Text);
XElement MyCustomers= XElement.Load(MyReader);
MyReader.Close();
string MyInfo =
(from MyElement in MyCustomers.Elements("客户")
select
String.Format("{0},{1},{2},{3},{4}",
(string)MyElement.Element("客户ID"),
(string)MyElement.Element("公司名称"),
(string)MyElement.Element("城市") + (string)MyElement.Element("地址"),
(string)MyElement.Element("联系人姓名"),
Environment.NewLine
)
).Take(10).Aggregate(new StringBuilder(),(MySubString, MyString)=>MySubString.Append(MyString),MySubString=>MySubString.ToString());
MessageBox.Show(MyInfo, "信息提示");
}
- 2023-04-08 15:00:04下载
- 积分:1
-
GA---matlab
通过matlab来实现遗传算法,利用遗传算法程序和遗传算法工具箱来实现该功能,具体应用效果很好(Matlab achieved through the genetic algorithm, the procedure using the genetic algorithm and genetic algorithm toolbox to achieve the function of specific application of effective)
- 2009-04-11 15:41:28下载
- 积分:1
-
C# 使用DrawPolygon方法绘制一个多边形
C# 调用Graphics对象的DrawPolygon方法绘制一个多边形,我们用代码定义多边形的每条边:Point point6 = new Point(160, 20); //实例化Point类,注意多边形的每个边都需要定义不同数据。
Point[] myPoints ={ point1, point2, point3, point4, point5, point6 };//创建Point结构数组
//调用Graphics对象的DrawPolygon方法绘制一个多边形
ghs.DrawPolygon(myPen, myPoints);
- 2022-02-03 12:31:32下载
- 积分:1
-
V0.0.2_0207
ADXL345工程,带软件近似卡尔曼滤波(ADXL345 PROJECT, )
- 2015-03-17 14:12:42下载
- 积分:1