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

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

資源簡介

VS平臺下c#利用TCP/IP通信協議與川崎機器人連接實現通信

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
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?TCP_Robot
{
????public?partial?class?Form1?:?Form
????{
????????public?Socket?newclient_Client;?//用于tcp通訊
????????bool?Connected_Client?=?false;?//用于判斷是否連接
????????public?Thread?myThread_client;//用于監聽
????????public?delegate?void?SetlblHandle(string?str);
????????public?Form1()
????????{
????????????InitializeComponent();
????????}

????????private?void?btnConn_Click(object?sender?EventArgs?e)
????????{
????????????ConnectRobot();
????????}
????????public?void?ConnectRobot()//鏈接tcp
????????{
????????????byte[]?data?=?new?byte[1024];
????????????newclient_Client?=?new?Socket(AddressFamily.InterNetwork?SocketType.Stream?ProtocolType.Tcp);
????????????string?ipadd?=?“192.168.30.238“;//機器人IP地址
????????????int?port?=?Convert.ToInt32(“23“);//端口號
????????????IPEndPoint?ie?=?new?IPEndPoint(IPAddress.Parse(ipadd)?port);
????????????try
????????????{
????????????????newclient_Client.Connect(ie);
????????????????Connected_Client?=?true;?????????
????????????????btnConn.Enabled?=?false;
????????????????sendToRobot(“as\r\n“);//建立連接后,首先發送as,則可以通過計算機發送as語言指令
????????????????SetTishi(“機器人鏈接成功...“);//顯示


????????????}
????????????catch?(SocketException?e)
????????????{
????????????????SetTishi(“連接機器人失敗??“?+?e.Message);
????????????????return;
????????????}

????????????ThreadStart?myThreaddelegate?=?new?ThreadStart(ReceiveMsg);
????????????myThread_client?=?new?Thread(myThreaddelegate);
????????????myThread_client.Start();


????????}
????????public?void?ReceiveMsg()//監聽tcp
????????{

????????????int?thelastData?=?999;
????????????while?(true)
????????????{
????????????????try
????????????????{

????????????????????byte[]?data?=?new?byte[1024];
????????????????????int?recv?=?newclient_Client.Receive(data);//接收消息
????????????????????string?stringdata?=?Encoding.UTF8.GetString(data?0?recv);//將bytes轉換為字符
????????????????????//string?stringdata?=?Encoding.Unicode.GetString(data?0?recv);
????????????????????if?(stringdata?==?““)//判斷是否端口連接
????????????????????{
????????????????????????SetTishi(“服務器已退出“);
????????????????????????newclient_Client.Close();
????????????????????????Connected_Client?=?false;
????????????????????????break;
????????????????????}
????????????????????//利用AS語言的檢測變量的指令list實現監聽功能
????????????????????//因為發送‘list/r?photo’監測變量photo的值返回的還有其它字符,所以要去掉這些字符
????????????????????stringdata?=?stringdata.Trim();
????????????????????string?strTemp?=?“photo????=“;
????????????????????int?iCount?=?stringdata.IndexOf(strTemp);//得到多余字符的長度
????????????????????if?(iCount?>?0)
????????????????????{
????????????????????????string?read?=?stringdata.Substring(strTemp.Length?+?iCount?+?1?2)

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-29?10:14??TCP_Robot\
?????目錄???????????0??2017-12-29?10:14??TCP_Robot\TCP_Robot\
?????文件?????????187??2017-12-28?15:43??TCP_Robot\TCP_Robot\App.config
?????文件????????2709??2017-12-28?15:53??TCP_Robot\TCP_Robot\Form1.Designer.cs
?????文件????????5766??2017-12-29?10:14??TCP_Robot\TCP_Robot\Form1.cs
?????文件????????5817??2017-12-28?15:53??TCP_Robot\TCP_Robot\Form1.resx
?????文件?????????521??2017-12-28?15:43??TCP_Robot\TCP_Robot\Program.cs
?????目錄???????????0??2017-12-28?15:43??TCP_Robot\TCP_Robot\Properties\
?????文件????????1360??2017-12-28?15:43??TCP_Robot\TCP_Robot\Properties\AssemblyInfo.cs
?????文件????????2870??2017-12-28?15:43??TCP_Robot\TCP_Robot\Properties\Resources.Designer.cs
?????文件????????5612??2017-12-28?15:43??TCP_Robot\TCP_Robot\Properties\Resources.resx
?????文件????????1096??2017-12-28?15:43??TCP_Robot\TCP_Robot\Properties\Settings.Designer.cs
?????文件?????????249??2017-12-28?15:43??TCP_Robot\TCP_Robot\Properties\Settings.settings
?????文件????????3798??2017-12-28?15:49??TCP_Robot\TCP_Robot\TCP_Robot.csproj
?????目錄???????????0??2017-12-28?15:43??TCP_Robot\TCP_Robot\bin\
?????目錄???????????0??2017-12-28?15:43??TCP_Robot\TCP_Robot\bin\Debug\
?????文件?????????187??2017-12-28?15:43??TCP_Robot\TCP_Robot\bin\Debug\TCP_Robot.exe.config
?????文件???????24224??2017-12-29?09:39??TCP_Robot\TCP_Robot\bin\Debug\TCP_Robot.vshost.exe
?????文件?????????187??2017-12-28?15:43??TCP_Robot\TCP_Robot\bin\Debug\TCP_Robot.vshost.exe.config
?????文件?????????490??2010-03-17?22:39??TCP_Robot\TCP_Robot\bin\Debug\TCP_Robot.vshost.exe.manifest
?????目錄???????????0??2017-12-28?15:43??TCP_Robot\TCP_Robot\obj\
?????目錄???????????0??2017-12-28?15:49??TCP_Robot\TCP_Robot\obj\Debug\
?????文件?????????865??2017-12-28?15:43??TCP_Robot\TCP_Robot\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????6931??2017-12-28?15:44??TCP_Robot\TCP_Robot\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件?????????180??2017-12-28?15:49??TCP_Robot\TCP_Robot\obj\Debug\TCP_Robot.Form1.resources
?????文件?????????180??2017-12-28?15:49??TCP_Robot\TCP_Robot\obj\Debug\TCP_Robot.Properties.Resources.resources
?????文件?????????390??2017-12-29?09:39??TCP_Robot\TCP_Robot\obj\Debug\TCP_Robot.csproj.FileListAbsolute.txt
?????文件?????????977??2017-12-28?15:49??TCP_Robot\TCP_Robot\obj\Debug\TCP_Robot.csproj.GenerateResource.Cache
?????文件????????2211??2017-12-28?15:49??TCP_Robot\TCP_Robot\obj\Debug\TCP_Robot.csprojResolveAssemblyReference.cache
?????目錄???????????0??2017-12-29?10:15??TCP_Robot\TCP_Robot\obj\Debug\TempPE\
?????文件???????????0??2017-12-28?15:43??TCP_Robot\TCP_Robot\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
............此處省略4個文件信息

評論

共有 條評論