91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

這是一個用C#寫的Socket服務器和客戶端,當然Socket服務器和客戶端不是主要的(有興趣的朋友可以參考下),主要的內容是介紹如何通過這種Socket方式發送Object對象。 作者博客 http://luyugao.com

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;

using?System.Threading;
using?System.Net;
using?System.Net.Sockets;
using?System.IO;
using?System.Runtime.Serialization.Formatters.Binary;

using?User;
//object對象是通過user類派生的,這里引用的是User.dll?
//??作者博客:?http://www.luyugao.com
namespace?Client
{
????public?partial?class?Client?:?Form
????{
????????public?Client()
????????{
????????????InitializeComponent();
????????}
????????Socket?mySocket;
????????///?
????????///?接收信息緩沖區大小
????????///?

????????int?packetSize?=?1024?*?50;
????????private?void?bt_lj_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????if?(tb_ip.Text.Trim()?!=?““?&&?tb_port.Text.Trim()?!=?““)
????????????????{
????????????????????IPEndPoint?iep;
????????????????????try
????????????????????{
????????????????????????iep?=?new?IPEndPoint(
????????????????????????????IPAddress.Parse(tb_ip.Text)?Convert.ToInt32(tb_port.Text)
????????????????????????????);
????????????????????}
????????????????????catch?(Exception?ex)?{?MessageBox.Show(ex.Message);?return;?}
????????????????????mySocket?=?new?Socket(AddressFamily.InterNetwork?SocketType.Stream?ProtocolType.Tcp);
????????????????????mySocket.Connect(iep);

????????????????????Thread?t?=?new?Thread(resMsg);
????????????????????t.IsBackground?=?true;
????????????????????t.Start();

????????????????????bt_lj.Enabled?=?false;
????????????????????bt_sendobject.Enabled?=?bt_sendStr.Enabled?=?true;
????????????????}
????????????}
????????????catch?(Exception?ex)?{?MessageBox.Show(ex.Message);?}

????????}
????????//object對象是通過user類派生的,這里引用的是User.dll?
????????//??作者博客:?http://www.luyugao.com
????????///?
????????///?循環接收信息
????????///?

????????void?resMsg()
????????{
????????????while?(true)
????????????{
????????????????byte[]?by?=?new?byte[packetSize];
????????????????int?length?=?-1;
????????????????try
????????????????{
????????????????????length?=?mySocket.Receive(by);
????????????????}
????????????????catch?(SocketException)?{?break;?}
????????????????catch?(Exception)?{?break;?}
????????????????if?(length?????????????????????continue;
????????????????string?_cmd?=?getMsgHead(by);
????????????????switch?(_cmd)
????????????????{
????????????????????case?“01“://文本消息
????????????????????????string?Msg?=?Encoding.UTF8.GetString(by?2?length?-?2);
????????????????????????showMsg(Msg);
????????????????????????break;
????????????????????case“02“://對象消息
?????????????????????????showMsg(“收到對象、信息如下:“);
????????????????????????byte[]?by1=new?byte[length-2];
????????????????????????Buffer.BlockCopy(by?2?by1?0?by1.Length);
????????????????????????object?_obj?=?Deserialize(by1);
????????????????????????user?_u?=?_obj?as?user;
????????????????????????string?s?=?st

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????16384??2013-07-18?17:28??Sendobject\Client\bin\Debug\Client.exe

?????文件??????34304??2013-07-18?17:28??Sendobject\Client\bin\Debug\Client.pdb

?????文件??????11608??2013-07-18?17:30??Sendobject\Client\bin\Debug\Client.vshost.exe

?????文件???????4096??2013-07-18?17:00??Sendobject\Client\bin\Debug\User.dll

?????文件???????8252??2013-07-18?17:28??Sendobject\Client\Client.cs

?????文件???????3631??2013-07-18?17:01??Sendobject\Client\Client.csproj

?????文件??????14119??2013-07-18?17:22??Sendobject\Client\Client.Designer.cs

?????文件???????5817??2013-07-18?17:22??Sendobject\Client\Client.resx

?????文件????????180??2013-07-18?17:22??Sendobject\Client\obj\x86\Debug\Client.Client.resources

?????文件????????691??2013-07-18?17:30??Sendobject\Client\obj\x86\Debug\Client.csproj.FileListAbsolute.txt

?????文件????????976??2013-07-18?17:22??Sendobject\Client\obj\x86\Debug\Client.csproj.GenerateResource.Cache

?????文件???????4257??2013-07-18?17:01??Sendobject\Client\obj\x86\Debug\Client.csprojResolveAssemblyReference.cache

?????文件??????16384??2013-07-18?17:28??Sendobject\Client\obj\x86\Debug\Client.exe

?????文件??????34304??2013-07-18?17:28??Sendobject\Client\obj\x86\Debug\Client.pdb

?????文件????????180??2013-07-18?17:01??Sendobject\Client\obj\x86\Debug\Client.Properties.Resources.resources

?????文件???????5419??2013-07-18?17:29??Sendobject\Client\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

?????文件????????468??2013-07-18?16:06??Sendobject\Client\Program.cs

?????文件???????1344??2013-07-18?16:06??Sendobject\Client\Properties\AssemblyInfo.cs

?????文件???????2864??2013-07-18?16:06??Sendobject\Client\Properties\Resources.Designer.cs

?????文件???????5612??2013-07-18?16:06??Sendobject\Client\Properties\Resources.resx

?????文件???????1093??2013-07-18?16:06??Sendobject\Client\Properties\Settings.Designer.cs

?????文件????????249??2013-07-18?16:06??Sendobject\Client\Properties\Settings.settings

?????文件??????14848??2013-07-18?17:21??Sendobject\Sendobject\bin\Debug\Sendobject.exe

?????文件??????34304??2013-07-18?17:21??Sendobject\Sendobject\bin\Debug\Sendobject.pdb

?????文件??????11608??2013-07-18?17:31??Sendobject\Sendobject\bin\Debug\Sendobject.vshost.exe

?????文件???????4096??2013-07-18?17:00??Sendobject\Sendobject\bin\Debug\User.dll

?????文件??????11718??2013-07-18?17:21??Sendobject\Sendobject\FServer.cs

?????文件???????5261??2013-07-18?17:18??Sendobject\Sendobject\FServer.Designer.cs

?????文件???????5817??2013-07-18?17:18??Sendobject\Sendobject\FServer.resx

?????文件????????789??2013-07-18?15:20??Sendobject\Sendobject\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

............此處省略57個文件信息

評論

共有 條評論