• 大小: 0.08M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-05
  • 语言: 其他
  • 标签: 其他  

资源简介

UDPServerClientTest.zip

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;

namespace UDPClient
{
    public partial class FrmClient : Form
    {
        public FrmClient()
        {
            InitializeComponent();
        }

        static string sendMsg = ““;
        static byte[] sendData = null;
         UdpClient _udpClient = new UdpClient();
        
        //发送数据按钮事件
        private void button1_Click(object sender EventArgs e)
        {
            IPAddress ServerIP = IPAddress.Parse(textBox1.Text.Trim());//将textBox1.text里面的值转换为ipaddress地址类型
            IPEndPoint ServerEndPoint = new IPEndPoint(ServerIP int.Parse(textBox2.Text));//实例化一个节点
            sendData = EncodingASCII(textBox3.Text.Trim());//发送数据
            _udpClient.Send(sendData sendData.Length ServerEndPoint);
        }

        //关闭连接按钮事件
        private void button2_Click(object sender EventArgs e)
        {
            if (button2.Text == “关闭连接“)
            {
                _udpClient.Close();
            }
        }

        public static byte[] EncodingASCII(string buf)//编码
        {
           // byte[] data = Encoding.ASCII.GetBytes(buf + “\r\n“);
            byte[] data = Encoding.ASCII.GetBytes(buf + “\r\n“);

            return data;
        }
        public static string DecodingASCII(byte[] buf)//解码
        {
            string st = Encoding.ASCII.GetString(buf);
            return st;
        }

       
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-04-10 17:03  UDPServerClientTest\
     目录           0  2016-04-10 17:06  UDPServerClientTest\UDPClient\
     目录           0  2016-04-10 17:06  UDPServerClientTest\UDPClient\bin\
     目录           0  2016-04-10 17:18  UDPServerClientTest\UDPClient\bin\Debug\
     文件       10752  2016-04-10 18:49  UDPServerClientTest\UDPClient\bin\Debug\UDPClient.exe
     文件       26112  2016-04-10 18:49  UDPServerClientTest\UDPClient\bin\Debug\UDPClient.pdb
     文件       11600  2016-04-10 18:55  UDPServerClientTest\UDPClient\bin\Debug\UDPClient.vshost.exe
     目录           0  2016-04-10 17:06  UDPServerClientTest\UDPClient\bin\Release\
     文件        1738  2016-04-10 18:36  UDPServerClientTest\UDPClient\FrmClient.cs
     文件        7106  2016-04-10 18:12  UDPServerClientTest\UDPClient\FrmClient.Designer.cs
     文件        5817  2016-04-10 18:12  UDPServerClientTest\UDPClient\FrmClient.resx
     目录           0  2016-04-10 17:02  UDPServerClientTest\UDPClient\obj\
     目录           0  2016-04-10 17:02  UDPServerClientTest\UDPClient\obj\x86\
     目录           0  2016-04-10 18:49  UDPServerClientTest\UDPClient\obj\x86\Debug\
     文件        2867  2016-04-10 17:02  UDPServerClientTest\UDPClient\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6423  2016-04-10 18:49  UDPServerClientTest\UDPClient\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2016-04-10 17:02  UDPServerClientTest\UDPClient\obj\x86\Debug\TempPE\
     文件         810  2016-04-10 18:55  UDPServerClientTest\UDPClient\obj\x86\Debug\UDPClient.csproj.FileListAbsolute.txt
     文件         979  2016-04-10 18:22  UDPServerClientTest\UDPClient\obj\x86\Debug\UDPClient.csproj.GenerateResource.Cache
     文件       10752  2016-04-10 18:49  UDPServerClientTest\UDPClient\obj\x86\Debug\UDPClient.exe
     文件         180  2016-04-10 18:22  UDPServerClientTest\UDPClient\obj\x86\Debug\UDPClient.FrmClient.resources
     文件       26112  2016-04-10 18:49  UDPServerClientTest\UDPClient\obj\x86\Debug\UDPClient.pdb
     文件         180  2016-04-10 18:22  UDPServerClientTest\UDPClient\obj\x86\Debug\UDPClient.Properties.Resources.resources
     文件         494  2016-04-10 17:06  UDPServerClientTest\UDPClient\Program.cs
     目录           0  2016-04-10 17:02  UDPServerClientTest\UDPClient\Properties\
     文件        1368  2016-04-10 17:02  UDPServerClientTest\UDPClient\Properties\AssemblyInfo.cs
     文件        2870  2016-04-10 17:02  UDPServerClientTest\UDPClient\Properties\Resources.Designer.cs
     文件        5612  2016-04-10 17:02  UDPServerClientTest\UDPClient\Properties\Resources.resx
     文件        1096  2016-04-10 17:02  UDPServerClientTest\UDPClient\Properties\Settings.Designer.cs
     文件         249  2016-04-10 17:02  UDPServerClientTest\UDPClient\Properties\Settings.settings
     文件        3697  2016-04-10 18:10  UDPServerClientTest\UDPClient\UDPClient.csproj
............此处省略31个文件信息

评论

共有 条评论