xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 37KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-23
  • 語言: C#
  • 標簽: tcp??c#??

資源簡介

本代碼基于c#語言實現tcp雙工通信,分為tcp客戶端和tcp服務器端兩部分,內含可執行文件。

資源截圖

代碼片段和文件信息

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

using?System.Net;
using?System.Net.Sockets;
using?System.Threading;
using?System.IO;?

namespace?tcp客戶端
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????????TextBox.CheckForIllegalCrossThreadCalls?=?false;??
????????}
????????Thread?threadClient?=?null;?//?創建用于接收服務端消息的?線程;???
????????Socket?sockClient?=?null;

????????private?void?btnConnect_Click(object?sender?EventArgs?e)
????????{
????????????IPAddress?ip?=?IPAddress.Parse(txtIp.Text.Trim());
????????????IPEndPoint?endPoint?=?new?IPEndPoint(ip?int.Parse(txtPort.Text.Trim()));
????????????sockClient?=?new?Socket(AddressFamily.InterNetwork?SocketType.Stream?ProtocolType.Tcp);
????????????try
????????????{
????????????????ShowMsg(“與服務器連接中……“);
????????????????sockClient.Connect(endPoint);

????????????}
????????????catch?(SocketException?se)
????????????{
????????????????MessageBox.Show(se.Message);
????????????????return;
????????????????//this.Close();???
????????????}
????????????ShowMsg(“與服務器連接成功!!!“);
????????????threadClient?=?new?Thread(RecMsg);
????????????threadClient.IsBackground?=?true;
????????????threadClient.Start();??

????????}
????????public?delegate?void?DeleUpdateTextbox(string?dataRe);
????????void?RecMsg()
????????{
????????????DeleUpdateTextbox?deleupdatetextbox?=?new?DeleUpdateTextbox(UpdateTextbox);
????????????byte[]?arrMsgRec?=?new?byte[1024?*?1024?*?512];
????????????while?(true)
????????????{
????????????????//?定義一個2M的緩存區;???
????????????????
????????????????//?將接受到的數據存入到輸入??arrMsgRec中;???
????????????????int?length?=?-1;
????????????????try
????????????????{
????????????????????length?=?sockClient.Receive(arrMsgRec);?//?接收數據,并返回數據的長度;???
????????????????????arrMsgRec[length]?=?0;
????????????????}
????????????????catch?(SocketException?se)
????????????????{
????????????????????ShowMsg(“異常;“?+?se.Message);
????????????????????return;
????????????????}
????????????????catch?(Exception?e)
????????????????{
????????????????????ShowMsg(“異常:“?+?e.Message);
????????????????????return;
????????????????}
????????????????if?(arrMsgRec[0]?==?0x30)?//?表示接收到的是消息數據;???
????????????????{
????????????????????string?strMsg;?//System.Text.Encoding.Default.GetString(arrMsgRec?1?length?-?1);//?將接受到的字節數據轉化成字符串;???
????????????????????//ShowMsg(strMsg);
????????????????????strMsg?=?System.Text.Encoding.UTF8.GetString(arrMsgRec?1?length?-?1);
????????????????????strMsg?=?“他說:\r\n“?+?strMsg;

????????????????????ShowMsg(strMsg);

????????????????}
????????????????if?(arrMsgRec[0]?==?0x31)?//?表示接收到的是文件數據;???
????????????????{

????????????????????try
????????????????????{
????????????????????????SaveFileDialog?sfd?=?new?SaveFileDialog();

??

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-04-20?20:24??tcp通信\
?????目錄???????????0??2018-05-01?20:31??tcp通信\tcp服務器\
?????文件???????11206??2018-04-27?22:09??tcp通信\tcp服務器\Form1.cs
?????文件????????8731??2018-04-27?22:09??tcp通信\tcp服務器\Form1.Designer.cs
?????文件????????5817??2018-04-27?22:09??tcp通信\tcp服務器\Form1.resx
?????文件?????????484??2018-04-17?22:27??tcp通信\tcp服務器\Program.cs
?????文件???????14336??2018-04-27?22:09??tcp通信\tcp服務器\tcp.exe
?????文件?????????851??2018-04-20?20:22??tcp通信\tcp服務器\tcp.sln
?????文件???????24576??2018-04-27?22:09??tcp通信\tcp服務器\tcp.suo
?????目錄???????????0??2018-05-01?20:31??tcp通信\tcp客戶端\
?????文件????????7897??2018-04-20?20:21??tcp通信\tcp客戶端\Form1.cs
?????文件????????8829??2018-04-20?20:21??tcp通信\tcp客戶端\Form1.Designer.cs
?????文件????????5817??2018-04-20?20:21??tcp通信\tcp客戶端\Form1.resx
?????文件?????????493??2018-04-17?22:40??tcp通信\tcp客戶端\Program.cs
?????文件???????13824??2018-04-27?22:04??tcp通信\tcp客戶端\tcp客戶端.exe
?????文件?????????878??2018-04-20?20:22??tcp通信\tcp客戶端\tcp客戶端.sln
?????文件???????24576??2018-04-27?22:09??tcp通信\tcp客戶端\tcp客戶端.suo

評論

共有 條評論