資源簡介
c#編的即時通訊工具,實現了局域網內即時通訊、文件傳輸、可擴展
代碼片段和文件信息
using?System.Text;
using?System.Net.Sockets;
using?System.Net;
using?System.Threading;
namespace?FeiXun2011
{
????///?
????///?自定義廣播類
????///?
????class?CustomBroadCast
????{
????????#region?Fields
????????private?UdpClient?_udpClient;
????????private?IPEndPoint?_ep;
????????private?string?_userName;
????????private?int?_phoIndex;
????????private?string?_computerInfo;
????????#endregion?Fields
????????#region?Properties
????????///?
????????///設置用戶名
????????///?
????????public?string?MyUserName
????????{
????????????set
????????????{
????????????????_userName?=?value;
????????????}
????????}
????????///?
????????///?設置用戶頭像索引
????????///?
????????public?int?MyPhoIndex
????????{
????????????set
????????????{
????????????????_phoIndex?=?value;
????????????}
????????}
????????#endregion?Properties
????????#region?Constructors
????????///?
????????///?構造函數
????????///?
????????///?用戶名
????????///?用戶頭像索引
????????public?CustomBroadCast(string?useName?int?phoIndex)
????????{
????????????_userName?=?useName;
????????????_phoIndex?=?phoIndex;
????????????IPAddress[]?ips?=?Dns.GetHostEntry(Dns.GetHostName()).AddressList;
????????????foreach?(IPAddress?ip?in?ips)//取當前IPV4本地地址
????????????{
????????????????string?t?=?ip.ToString();
????????????????int?a?=?t.Length;
????????????????if?(ip.ToString().Length?<=?15)
????????????????{
????????????????????_computerInfo?=?ip.ToString();//第一個長度不大于15為IPv4地址本地地址
????????????????????break;
????????????????}
????????????}
????????}
????????#endregion?Constructors
????????#region?Methods
????????///?
????????///?不斷向局域網內廣播告訴其它用戶在線數據格式?是否退出?頭像?用戶名?ip
????????///?
????????public?void?BroadCast()
????????{
????????????_udpClient?=?new?UdpClient();
????????????_ep?=?new?IPEndPoint(IPAddress.Broadcast?7999);
????????????byte[]?buff;
????????????try
????????????{
????????????????while?(true)
????????????????{
????????????????????string?userInfo?=“1#“+_phoIndex?+?“#“?+?_userName?+?“#“?+?_computerInfo+“#“+“8001“;
????????????????????buff?=?Encoding.UTF8.GetBytes(userInfo);
????????????????????_udpClient.Send(buff?buff.Length?_ep);
????????????????????Thread.Sleep(2000);//每隔2秒廣播一次
????????????????}
????????????}
????????????catch
????????????{
????????????????return;
????????????}
????????}
????????///?
????????///?退出時向局域網中發退出信息“0”
????????///?
????????public?void?BroadExit()
????????{
????????????string?computerExitInfo?=?“0#“?+?_phoIndex?+?“#“?+?_userName?+?“#“?+?_computerInfo?+?“#“?+?“8001“;
????????????byte[]?buff?=?Encoding.UTF8.GetBytes(computerExitInfo);
????????????_udpClient.Send(buff?buff.Length?_ep);
????????????_udpClient.Close();
????????}
????????#endregion?Methods
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2143??2014-07-04?11:06??FeiXun\FeiXun.sln
????..A..H.?????71168??2014-07-04?13:00??FeiXun\FeiXun.v12.suo
?????文件????????363??2014-07-04?11:12??FeiXun\FeiXun2014\App.config
?????文件??????53248??2009-11-21?20:48??FeiXun\FeiXun2014\bin\Debug\AxInterop.WMPLib.dll
?????文件????3178496??2008-09-09?09:54??FeiXun\FeiXun2014\bin\Debug\DevComponents.DotNetBar2.dll
?????文件?????137407??2011-05-29?18:34??FeiXun\FeiXun2014\bin\Debug\FeiXun2011.rar
?????文件????????308??2014-07-04?11:03??FeiXun\FeiXun2014\bin\Debug\FeiXun2011.vshost.exe.config
?????文件?????376320??2014-07-04?11:35??FeiXun\FeiXun2014\bin\Debug\FeiXun2014.exe
?????文件????????363??2014-07-04?11:12??FeiXun\FeiXun2014\bin\Debug\FeiXun2014.exe.config
?????文件?????110080??2014-07-04?11:35??FeiXun\FeiXun2014\bin\Debug\FeiXun2014.pdb
?????文件??????22712??2014-07-04?11:37??FeiXun\FeiXun2014\bin\Debug\FeiXun2014.vshost.exe
?????文件????????363??2014-07-04?11:12??FeiXun\FeiXun2014\bin\Debug\FeiXun2014.vshost.exe.config
?????文件??????11264??2014-07-04?11:13??FeiXun\FeiXun2014\bin\Debug\FeiXunCommon.dll
?????文件??????30208??2014-07-04?11:13??FeiXun\FeiXun2014\bin\Debug\FeiXunCommon.pdb
?????文件?????172116??2011-05-21?18:02??FeiXun\FeiXun2014\bin\Debug\FeiXunStart.exe
?????文件???????1013??2006-05-08?10:17??FeiXun\FeiXun2014\bin\Debug\image\crit_16.gif
?????文件????????824??2004-10-29?15:46??FeiXun\FeiXun2014\bin\Debug\image\down.bmp
?????文件????????283??2005-11-12?00:00??FeiXun\FeiXun2014\bin\Debug\image\exportd.gif
?????文件????????824??2004-10-29?15:22??FeiXun\FeiXun2014\bin\Debug\image\Folder.bmp
?????文件????????246??2004-08-20?03:21??FeiXun\FeiXun2014\bin\Debug\image\FontDialog.bmp
?????文件????????824??2004-10-29?15:22??FeiXun\FeiXun2014\bin\Debug\image\Open.bmp
?????文件???????1236??2005-11-12?00:00??FeiXun\FeiXun2014\bin\Debug\image\refresh_over.gif
?????文件??????11264??2011-05-24?22:17??FeiXun\FeiXun2014\bin\Debug\image\Thumbs.db
?????文件????????824??2004-10-29?15:46??FeiXun\FeiXun2014\bin\Debug\image\up.bmp
?????文件?????274432??2011-05-10?21:16??FeiXun\FeiXun2014\bin\Debug\Interop.WMPLib.dll
?????文件???????7168??2014-07-04?11:33??FeiXun\FeiXun2014\bin\Debug\OwnInfo.db3
?????文件???????4825??1998-10-29?17:43??FeiXun\FeiXun2014\bin\Debug\sounds\Global.wav
?????文件???????9220??1998-05-02?04:01??FeiXun\FeiXun2014\bin\Debug\sounds\msg.wav
?????文件??????15326??2002-09-11?12:23??FeiXun\FeiXun2014\bin\Debug\sounds\ring.wav
?????文件???????9216??2011-12-23?17:47??FeiXun\FeiXun2014\bin\Debug\SQLiteDBHelper.dll
............此處省略198個文件信息
- 上一篇:c#SQL數據庫課程設計 整合版
- 下一篇:酒店管理系統,與數據庫
評論
共有 條評論