资源简介
即时通信.zip
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace New_QQ
{
public partial class Form1 : Form
{
private static IPAddress clientIP;
public static IPEndPoint clientIPEndPoint;
private static UdpClient receiveUdpClient;
private static IPEndPoint remoteIpEndPoint;
private static IPEndPoint serverIpEndPoint;
private static TcpClient tcpClient;
public static UdpClient sendUdpClient;
public static UdpClient chatClient;
private static string userListstring;
private static BinaryReader binaryReader;
private static NetworkStream networkStream;
private static Thread receiveThread;
private static Thread sendThread;
public Form1()
{
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
}
private void button1_Click(object sender EventArgs e)
{
//创建接受套接字
clientIP = IPAddress.Parse(txtLocalIP.Text);
clientIPEndPoint = new IPEndPoint(clientIP int.Parse(txtlocalport.Text));
serverIpEndPoint=new IPEndPoint(IPAddress.Parse(txtserverIP.Text)int.Parse(txtServerPort.Text) );
receiveUdpClient = new UdpClient(clientIPEndPoint);
//启动接受线程
receiveThread = new Thread(ReceiveMessage);
receiveThread.Start();
//匿名发送
sendUdpClient = new UdpClient(0);
//启动发送线程
sendThread = new Thread(SendMessage);
sendThread.Start(string.Format(“login{0}{1}“ txtusername.Text clientIPEndPoint));
button1.Enabled = false;
this.Text = txtusername.Text;
button2.Enabled = true;
this.ControlBox = false;
}
private void ReceiveMessage()
{
remoteIpEndPoint = new IPEndPoint(IPAddress.Any 0);
while (true)
{
try
{
//关闭receiveUdpClient时会产生异常
byte[] receiveBytes = receiveUdpClient.Receive(ref remoteIpEndPoint);
string message = Encoding.Unicode.GetString(receiveBytes 0 receiveBytes.Length);
//处理消息
string[] splitstring = message.Split(‘‘);
switch (splitstring[0])
{
case “Accept“:
try
{
tcpClient = new TcpClient();
tcpClient.Connect(remoteIpEndPoint.Address int.Parse(txtServerPort.Text));
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 187 2016-11-10 21:22 New QQ\App.config
文件 12800 2016-11-11 21:57 New QQ\bin\Debug\New QQ.exe
文件 187 2016-11-10 21:22 New QQ\bin\Debug\New QQ.exe.config
文件 26112 2016-11-11 21:57 New QQ\bin\Debug\New QQ.pdb
文件 23168 2016-11-11 21:58 New QQ\bin\Debug\New QQ.vshost.exe
文件 187 2016-11-10 21:22 New QQ\bin\Debug\New QQ.vshost.exe.config
文件 490 2010-03-17 22:39 New QQ\bin\Debug\New QQ.vshost.exe.manifest
文件 6005 2016-11-11 21:57 New QQ\Form1.cs
文件 8431 2016-11-11 21:57 New QQ\Form1.Designer.cs
文件 5817 2016-11-11 21:57 New QQ\Form1.resx
文件 3792 2016-11-10 22:25 New QQ\New QQ.csproj
文件 1453 2016-11-11 21:01 New QQ\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6923 2016-11-10 21:32 New QQ\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 573 2016-11-11 22:08 New QQ\obj\Debug\New QQ.csproj.FileListAbsolute.txt
文件 977 2016-11-11 21:57 New QQ\obj\Debug\New QQ.csproj.GenerateResource.Cache
文件 2211 2016-11-10 22:25 New QQ\obj\Debug\New QQ.csprojResolveAssemblyReference.cache
文件 12800 2016-11-11 21:57 New QQ\obj\Debug\New QQ.exe
文件 26112 2016-11-11 21:57 New QQ\obj\Debug\New QQ.pdb
文件 180 2016-11-11 21:57 New QQ\obj\Debug\New_QQ.Form1.resources
文件 180 2016-11-10 22:25 New QQ\obj\Debug\New_QQ.Properties.Resources.resources
文件 0 2016-11-10 21:23 New QQ\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2016-11-10 21:23 New QQ\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2016-11-10 21:23 New QQ\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 529 2016-11-10 21:23 New QQ\Program.cs
文件 1442 2016-11-10 21:23 New QQ\Properties\AssemblyInfo.cs
文件 2842 2016-11-10 21:23 New QQ\Properties\Resources.Designer.cs
文件 5612 2016-11-10 21:22 New QQ\Properties\Resources.resx
文件 1093 2016-11-10 21:23 New QQ\Properties\Settings.Designer.cs
文件 249 2016-11-10 21:22 New QQ\Properties\Settings.settings
目录 0 2016-11-10 21:23 New QQ\obj\Debug\TempPE
............此处省略10个文件信息
- 上一篇:用遗传算法解决TSP问题
- 下一篇:EDA课程设计-电子密码锁.zip
相关资源
- 北京大学数字电路实验电路仿真数字
- hws.dll
- Burp_suite_Pro_v2.1.txt
- CC2530原理图元件库.zip
- 最优化导论答案.txt
- 计算机组成原理课后答案.pdf
- 百度云链接.rar
- 4.8-接插件-脚距3.96.SchLib
- meanshift算法实现.rar
- 换行插件.rar
- BC35.rar
- AnalysationofTrafficParaments.rar
- InvestigationofCar-speed.rar
- InvestigationofTrafficFlowing.rar
- vs2010破解版百度链接.rar
- 83390098XN297test.rar
- a4a957981f8dcf0175898b01a6478bfd.pdf
- 新建文本文档.txt59604
- 所有.txt
- 链接.zip
- 2019_全国大学生电子设计大赛_D题_简易
- 496782016年四川省TI杯大学生电子设计竞
- springboot.zip
- TIJ4-code.zip
- chrome.r39.crx
- pure_mathmodel_origin.slx
- pe_virus.rar
- wifi字典百度云链接.txt
- 微擎模块-人人商城.txt
- batcopyv2.0.zip
评论
共有 条评论