仿飞秋局域网聊天工具
using System; 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 WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private int port = 49151; private UdpClient udpclient; delegate void AppendString(sendData sendDatas);//添加用户列表委托 AppendString appendString; delegate void AppendStrings(string text);//添加广播消息委托 AppendStrings appendStrings; delegate void AppendStringGB(sendData text);//添加私人消息委托 AppendStringGB appendStringGB; public sendData sendDatas = new sendData(); IPHostEntry myentry; IPAddress myIp; Thread MyRecData; private void Form1_Load(object sender, EventArgs e) { udpclient = new UdpClient(port); myentry = Dns.GetHostEntry(Dns.GetHostName()); IPselect(); sendDatas.fromIP = myIp; sendDatas.toIP = IPAddress.Parse("255.255.255.255"); sendDatas.content = ""; appendString = new AppendString(AppString); appendStrings = new AppendStrings(AppStrings); appendStringGB = new AppendStringGB(AppStringGB); MyRecData = new Thread(new ThreadStart(RecData)); MyRecData.IsBackground = true; MyRecData.Start(); States(); } /// /// 广播本机IP /// public void States() { IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast, port); byte[] sen = Class2.senDataToByte(sendDatas); udpclient.Send(sen, sen.Length, iep); } /// /// 获取本机IP /// public void IPselect()//查找本机第一个IP地址 { s
文件列表
TcpIpTest多人聊天.zip
(预估有个37文件)
TcpIpTest多人聊天
WindowsFormsApplication2
bin
Debug
WindowsFormsApplication2.application
2KB
WindowsFormsApplication2.pdb
42KB
WindowsFormsApplication2.exe
17KB
WindowsFormsApplication2.vshost.exe.config
120B
WindowsFormsApplication2.vshost.application
2KB
WindowsFormsApplication2.exe.manifest
3KB
暂无评论