<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      在ubuntu上配置dotnet環境再跑個C#程序做套接字通信

      參考微軟官方知識庫

      添加存儲庫

      sudo add-apt-repository ppa:dotnet/backports
      

      安裝 SDK

      sudo apt-get update && sudo apt-get install -y dotnet-sdk-9.0
      

      安裝運行時

      安裝ASP.NET Core 運行時

      sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-9.0
      

      或者

      安裝不包含 ASP.NET Core 支持的 .NET 運行時

      sudo apt-get update && sudo apt-get install -y dotnet-runtime-9.0
      

      編個程序測試下

      dotnet new console -o SocketServer
      
      Welcome to .NET 9.0!
      ---------------------
      SDK Version: 9.0.107
      
      ----------------
      Installed an ASP.NET Core HTTPS development certificate.
      To trust the certificate, run 'dotnet dev-certs https --trust'
      Learn about HTTPS: https://aka.ms/dotnet-https
      
      ----------------
      Write your first app: https://aka.ms/dotnet-hello-world
      Find out what's new: https://aka.ms/dotnet-whats-new
      Explore documentation: https://aka.ms/dotnet-docs
      Report issues and find source on GitHub: https://github.com/dotnet/core
      Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
      --------------------------------------------------------------------------------------
      The template "Console App" was created successfully.
      
      Processing post-creation actions...
      Restoring /home/siit/donetscript/SocketServer/SocketServer.csproj:
      Restore succeeded.
      

      反饋信息里給出了一大溜學習資源,這個培養用戶的手法是真不錯。
      繼續繼續,CD進路徑。

      cd SocketServer
      

      使用Nano打開Program.cs,并寫入以下代碼。

      using System;
      using System.Net;
      using System.Net.Sockets;
      using System.Text;
      
      class Program
      {
          static void Main()
          {
              int port = 11000;
      
              IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, port);
      
              using (Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
              {
                  listener.Bind(localEndPoint);
                  listener.Listen(10);
      
                  Console.WriteLine($"Server is running on port {port}. Accepting connections...");
      
                  while (true)
                  {
                      Console.WriteLine("Waiting for a client to connect...");
                      using (Socket handler = listener.Accept())
                      {
                          Console.WriteLine("Client connected. Ready to receive messages:");
      
                          byte[] buffer = new byte[1024];
      
                          while (true)
                          {
                              int received = handler.Receive(buffer);
                              if (received == 0)
                              {
                                  Console.WriteLine("Client disconnected.");
                                  break;
                              }
      
                              string message = Encoding.ASCII.GetString(buffer, 0, received);
                              Console.WriteLine("Received: " + message);
      
                              string reply = $"Echo: {message}<EOF>";
                              byte[] replyBytes = Encoding.ASCII.GetBytes(reply);
                              handler.Send(replyBytes);
                          }
                      }
                  }
              }
          }
      }
      

      然后運行一下

      dotnet run
      

      看到反饋:

      SocketServer$ dotnet run
      Server is running on port 11000. Accepting connections...
      Waiting for a client to connect...
      

      然后通過另一臺電腦,使用NetAssist去連接這臺服務器。套接字通信和NetAssist下載看這篇
      image
      可以在服務器端看到

      Client connected. Ready to receive messages:
      

      客戶端發送Hello,可以看到服務器的Echo。
      image
      同時在服務器終端可以看到

      Received: Hello
      

      下一步就準備把這段套接字通信的內容和視覺部分程序結合起來,就可以實現外部設備比如機器人或者PLC等觸發視覺拍照獲取坐標信息等內容的交互了。

      posted @ 2025-07-04 10:08  科里布  閱讀(44)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 色综合国产一区二区三区| 国产精品自拍中文字幕| 国内精品无码一区二区三区 | 亚洲欧洲日韩国内高清| 老妇肥熟凸凹丰满刺激| 自偷自拍亚洲综合精品| 久久人妻av无码中文专区| 久久国产精品伊人青青草| 中文字幕国产精品自拍| 亚洲欧美综合人成在线| 中文字幕精品亚洲字幕成| 国产视色精品亚洲一区二区| 日韩精品久久久肉伦网站| 久久超碰97人人做人人爱| 色综合一本到久久亚洲91| av一区二区中文字幕| 青青青青久久精品国产| 性色av不卡一区二区三区| 亚欧洲乱码视频在线专区| 久久香蕉欧美精品| 久久精品免费观看国产| 午夜男女爽爽影院在线| 久久久久国产精品人妻| 亚洲精品第一页中文字幕| 日日碰狠狠躁久久躁综合小说 | 无码精品人妻一区二区三区中| 成人网站免费观看| 亚洲综合一区二区三区视频| 最新AV中文字幕无码专区| 亚洲av男人电影天堂热app| 国产va免费精品观看精品 | 精品亚洲无人区一区二区| 免费AV片在线观看网址| 老色鬼在线精品视频在线观看| 久久精品国产字幕高潮| 日韩AV高清在线看片| 亚洲色偷拍区另类无码专区 | 国产日韩一区二区在线看| 午夜福利片1000无码免费| 国产精品一码二码三码| 亚洲一区二区三区影院|