資源簡介
實驗內容:基于服務器的客戶端相互直接通信
具體要求包括:
1,Server支持多客戶訪問;
2,C與S之間使用TCP連接;
3,C與C之間直接通信(不是通過S傳遞)。
4,C與C之間直接通信既可以使用TCP,也可以使用UDP。
5,可以使用Socket,也可以使用TcpClient/UdpClient等;
代碼片段和文件信息
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?SyncChatClient
{
????public?partial?class?Client?:?Form
????{
????????private?bool?isExit?=?false;
????????private?TcpClient?client;
????????private?BinaryReader?br;
????????private?BinaryWriter?bw;
????????private?List?userList?=?new?List();
????????private?TcpListener?myListener;
????????IPAddress?localAddress;
????????private?static?int?myport;
????????public?Client()
????????{
????????????InitializeComponent();
????????????Random?r?=?new
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-04-15?15:47??ex2(c-c)\
?????目錄???????????0??2017-04-15?15:47??ex2(c-c)\.vs\
?????目錄???????????0??2017-04-14?23:03??ex2(c-c)\.vs\ex2\
?????目錄???????????0??2017-04-14?23:03??ex2(c-c)\.vs\ex2\v14\
?????文件???????72704??2017-04-16?17:53??ex2(c-c)\.vs\ex2\v14\.suo
?????文件????????1496??2017-04-02?14:37??ex2(c-c)\ex2.sln
?????目錄???????????0??2017-04-16?15:06??ex2(c-c)\SyncChatClient\
?????文件?????????189??2017-04-02?14:36??ex2(c-c)\SyncChatClient\App.config
?????目錄???????????0??2017-04-14?23:03??ex2(c-c)\SyncChatClient\bin\
?????目錄???????????0??2017-04-14?23:03??ex2(c-c)\SyncChatClient\bin\Debug\
?????文件???????17408??2017-04-16?15:06??ex2(c-c)\SyncChatClient\bin\Debug\SyncChatClient.exe
?????文件?????????189??2017-04-02?14:36??ex2(c-c)\SyncChatClient\bin\Debug\SyncChatClient.exe.config
?????文件???????34304??2017-04-16?15:06??ex2(c-c)\SyncChatClient\bin\Debug\SyncChatClient.pdb
?????文件???????22696??2017-04-16?17:31??ex2(c-c)\SyncChatClient\bin\Debug\SyncChatClient.vshost.exe
?????文件?????????189??2017-04-02?14:36??ex2(c-c)\SyncChatClient\bin\Debug\SyncChatClient.vshost.exe.config
?????文件?????????490??2016-07-16?19:44??ex2(c-c)\SyncChatClient\bin\Debug\SyncChatClient.vshost.exe.manifest
?????目錄???????????0??2017-04-02?14:38??ex2(c-c)\SyncChatClient\bin\Release\
?????文件???????11644??2017-04-16?15:06??ex2(c-c)\SyncChatClient\Client.cs
?????文件????????8759??2017-04-16?12:25??ex2(c-c)\SyncChatClient\Client.Designer.cs
?????文件????????5817??2017-04-16?12:25??ex2(c-c)\SyncChatClient\Client.resx
?????目錄???????????0??2017-04-14?23:03??ex2(c-c)\SyncChatClient\obj\
?????目錄???????????0??2017-04-16?15:07??ex2(c-c)\SyncChatClient\obj\Debug\
?????文件????????1464??2017-04-14?10:47??ex2(c-c)\SyncChatClient\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????7454??2017-04-16?17:50??ex2(c-c)\SyncChatClient\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件?????????180??2017-04-16?12:25??ex2(c-c)\SyncChatClient\obj\Debug\SyncChatClient.Client.resources
?????文件????????1976??2017-04-16?17:31??ex2(c-c)\SyncChatClient\obj\Debug\SyncChatClient.csproj.FileListAbsolute.txt
?????文件????????1013??2017-04-16?12:25??ex2(c-c)\SyncChatClient\obj\Debug\SyncChatClient.csproj.GenerateResource.Cache
?????文件????????2384??2017-04-14?12:55??ex2(c-c)\SyncChatClient\obj\Debug\SyncChatClient.csprojResolveAssemblyReference.cache
?????文件???????17408??2017-04-16?15:06??ex2(c-c)\SyncChatClient\obj\Debug\SyncChatClient.exe
?????文件???????34304??2017-04-16?15:06??ex2(c-c)\SyncChatClient\obj\Debug\SyncChatClient.pdb
?????文件?????????180??2017-04-15?14:46??ex2(c-c)\SyncChatClient\obj\Debug\SyncChatClient.Properties.Resources.resources
............此處省略53個文件信息
- 上一篇:c# 小型的文字編輯工具源碼
- 下一篇:C# 簡易聊天軟件(socket編程)
評論
共有 條評論