資源簡介
C# Socket登錄驗證
一、說明
本程序只是學習應用Socket登錄驗證和序列化、反序列化的應用,所以只使用了最基本Socket函數,不是框架。
為了便于學習,服務端使用Access數據庫,如需修改數據庫內的圖片,自建程序文件,寫代碼:
for (int i=0;i<29;i )
{
byte[] imagebytes = ReadImageFile(i ".jpg");
OleDbCommand com = new OleDbCommand("UPDATE UserInfo SET User_Portrait=(@ImageList) WHERE id=" (i 1), Conn);
com.Parameters.Add("ImageList", OleDbType.Binary);
com.Parameters["ImageList"].Value = imagebytes;
com.ExecuteNonQuery();
}
將圖片更新到數據庫中,本程序中限定圖像大小為80*80。
數據結構定義在dataStructure.cs,每條傳輸數據生成新的驗證碼,根據驗證解密,見每個class中的SecretKey。
總的密鑰:
string sKey = "㊣o(╥﹏╥)o"; // 密鑰8位
服務端客戶端要一致。
private string ServerAddress = "服務器ip"; // 服務器ip地址
public static int port = 51888; // 使用的端口號
Server服務端與客戶端一致,Form1.cs。
private IPAddress[] ServerAddress = Dns.GetHostAddresses("服務器ip"); // 服務器ip地址
private int port = 51888; // 使用的端口號
編譯后先執行Server.exe,再執行Client.exe,
用戶名1000至1028,密碼為123456
三、使用的組件和修改
界面使用:http://www.haolizi.net/example/view_14426.html 的SQK.DLL
修改了UiScrollBoxMethod.cs,增加了滾動到最底部函數,自行編寫:
SetBottom()函數
......
foreach (UiControlsMethod.ADraggableGDIObject item in m_DraggableGDIObjects)
{
set_y = limtY;
......
item.Region = new Rectangle(0, set_y, item.Region.Width, item.Region.Height);
ScrollBox_.Invalidate();
}
修改了UiInputBoxMethods.cs,解決了粘貼帶文字樣式的問題,本程序中沒有使用,可以參照本程序INputForm.cs自行修改。
四、Win7、Win8都可運行,建議Win10運行,效果更好,Vs2017編譯,2015也可以。
.Net4.6.1,如其他版本,需重新編譯http://www.haolizi.net/example/view_14426.html 的SQK.DLL
一、說明
本程序只是學習應用Socket登錄驗證和序列化、反序列化的應用,所以只使用了最基本Socket函數,不是框架。
為了便于學習,服務端使用Access數據庫,如需修改數據庫內的圖片,自建程序文件,寫代碼:
for (int i=0;i<29;i )
{
byte[] imagebytes = ReadImageFile(i ".jpg");
OleDbCommand com = new OleDbCommand("UPDATE UserInfo SET User_Portrait=(@ImageList) WHERE id=" (i 1), Conn);
com.Parameters.Add("ImageList", OleDbType.Binary);
com.Parameters["ImageList"].Value = imagebytes;
com.ExecuteNonQuery();
}
將圖片更新到數據庫中,本程序中限定圖像大小為80*80。
數據結構定義在dataStructure.cs,每條傳輸數據生成新的驗證碼,根據驗證解密,見每個class中的SecretKey。
總的密鑰:
string sKey = "㊣o(╥﹏╥)o"; // 密鑰8位
服務端客戶端要一致。
二、使用
Client客戶端設置服務器地址,可以是本機,Login_Form.cs。private string ServerAddress = "服務器ip"; // 服務器ip地址
public static int port = 51888; // 使用的端口號
Server服務端與客戶端一致,Form1.cs。
private IPAddress[] ServerAddress = Dns.GetHostAddresses("服務器ip"); // 服務器ip地址
private int port = 51888; // 使用的端口號
編譯后先執行Server.exe,再執行Client.exe,
用戶名1000至1028,密碼為123456
三、使用的組件和修改
界面使用:http://www.haolizi.net/example/view_14426.html 的SQK.DLL
修改了UiScrollBoxMethod.cs,增加了滾動到最底部函數,自行編寫:
SetBottom()函數
......
foreach (UiControlsMethod.ADraggableGDIObject item in m_DraggableGDIObjects)
{
set_y = limtY;
......
item.Region = new Rectangle(0, set_y, item.Region.Width, item.Region.Height);
ScrollBox_.Invalidate();
}
修改了UiInputBoxMethods.cs,解決了粘貼帶文字樣式的問題,本程序中沒有使用,可以參照本程序INputForm.cs自行修改。
四、Win7、Win8都可運行,建議Win10運行,效果更好,Vs2017編譯,2015也可以。
.Net4.6.1,如其他版本,需重新編譯http://www.haolizi.net/example/view_14426.html 的SQK.DLL
代碼片段和文件信息
using?System;
using?System.Drawing;
using?System.Drawing.Drawing2D;
using?System.Linq;
using?System.Runtime.InteropServices;
using?System.Text.Regularexpressions;
using?System.Windows.Forms;
using?static?Client.DataStructure;
namespace?Client
{
????///?
????///?顯示信息窗體
????///?
????public?class?appForm
????{
????????public?AlphaForm?Afrm;
????????public?UiControlsMethod.PanelEx?panel_ListMessage;
????????UiScrollBoxMethod?scroll_Meesga;
????????UiDrawTextMethod?ds?=?new?UiDrawTextMethod();
????????Font?fnt?=?new?Font(“微軟雅黑“?9?Fontstyle.Regular);
????????RichTextBoxEx?rich_conter;
????????TextBox?tmpFocus;
????????int?Line_width?Line_height;?//顯示對話內容容器的寬度和高度
????????int?Message_Height?=?30;
????????public?IntPtr?Handle?{?get;?private?se
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????84992??2018-03-25?21:54??Client\.vs\Client\v15\.suo
?????文件??????????0??2018-03-17?20:46??Client\.vs\Client\v15\Server\sqlite3\db.lock
?????文件????1994752??2018-03-25?21:26??Client\.vs\Client\v15\Server\sqlite3\storage.ide
?????文件????????186??2018-03-18?18:54??Client\Client\App.config
?????文件??????17066??2018-03-25?21:21??Client\Client\appForm.cs
?????文件????6488576??2018-03-25?21:54??Client\Client\bin\Debug\Client.exe
?????文件????????186??2018-03-18?18:54??Client\Client\bin\Debug\Client.exe.config
?????文件??????77312??2018-03-25?21:54??Client\Client\bin\Debug\Client.pdb
?????文件?????165548??2017-11-04?19:24??Client\Client\bin\Debug\fontawesome-webfont.ttf
?????文件??????47926??2002-05-02?04:05??Client\Client\bin\Debug\Paintdrp.ttf
?????文件???????1089??2018-03-25?11:22??Client\Client\bin\Debug\ResFile\0-min.png
?????文件??????16058??2018-03-24?22:23??Client\Client\bin\Debug\ResFile\0.png
?????文件???????1118??2018-03-25?11:25??Client\Client\bin\Debug\ResFile\1-min.png
?????文件??????16094??2018-03-24?22:25??Client\Client\bin\Debug\ResFile\1.png
?????文件???????1094??2018-03-25?11:24??Client\Client\bin\Debug\ResFile\10-min.png
?????文件??????16080??2018-03-24?22:27??Client\Client\bin\Debug\ResFile\10.png
?????文件???????1140??2018-03-25?11:24??Client\Client\bin\Debug\ResFile\11-min.png
?????文件??????16135??2018-03-24?22:30??Client\Client\bin\Debug\ResFile\11.png
?????文件???????1129??2018-03-25?11:24??Client\Client\bin\Debug\ResFile\12-min.png
?????文件??????16130??2018-03-24?22:29??Client\Client\bin\Debug\ResFile\12.png
?????文件???????1090??2018-03-25?11:24??Client\Client\bin\Debug\ResFile\13-min.png
?????文件??????16092??2018-03-24?22:29??Client\Client\bin\Debug\ResFile\13.png
?????文件???????1156??2018-03-25?11:24??Client\Client\bin\Debug\ResFile\14-min.png
?????文件??????16102??2018-03-24?22:29??Client\Client\bin\Debug\ResFile\14.png
?????文件???????1077??2018-03-25?11:24??Client\Client\bin\Debug\ResFile\15-min.png
?????文件??????16044??2018-03-24?22:29??Client\Client\bin\Debug\ResFile\15.png
?????文件???????1162??2018-03-25?11:24??Client\Client\bin\Debug\ResFile\16-min.png
?????文件??????16220??2018-03-24?22:29??Client\Client\bin\Debug\ResFile\16.png
?????文件???????1111??2018-03-25?11:24??Client\Client\bin\Debug\ResFile\17-min.png
?????文件??????16089??2018-03-24?22:29??Client\Client\bin\Debug\ResFile\17.png
............此處省略114個文件信息
評論
共有 條評論