第一范文网 - 专业文章范例文档资料分享平台

上海大学 计算机网络 实验报告

来源:用户分享 时间:2025/9/14 15:25:09 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

页眉 using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;

using System.Windows.Forms; using System.Net;

using System.Net.Sockets; using System.Threading; namespace UDP接收端 {

public partial class UdpReceiveForm : Form {

private bool ReadFlag = true; private Thread th;

private IPEndPoint remote; private UdpClient server; private int count = 0; private double num; public UdpReceiveForm() {

InitializeComponent(); }

private void read() { try {

server = new UdpClient(8010);//创建端口为8010的socket } catch

21 / 22

页眉 {

MessageBox.Show(\创建端口失败!\, \错误\); return; }

Encoding enc = Encoding.Unicode; remote = null; while (true) {

Byte[] data = server.Receive(ref remote); String strData = enc.GetString(data);

this.lbReceiveMessage.Items.Insert(0, strData); } // while }

private void btnReceive_Click(object sender, EventArgs e) {

//创建一个线程

th = new Thread(new ThreadStart(read));//执行read函数 //启动线程 th.Start();

this.lblInfo.Text = \程序处于数据接收状态!\; }

private void UdpReceiveForm_FormClosing(object sender, FormClosingEventArgs e) {

if (th != null && th.ThreadState != ThreadState.Stopped) th.Abort(); } } }

22 / 22

搜索更多关于: 上海大学 计算机网络 实验报告 的文档
上海大学 计算机网络 实验报告.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c8xpve2suua7d82u9zjlx7yogl1itcy00ire_6.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top