總覽鏈接:
https://blog.csdn.net/a1234012340a/article/details/91040073
經過前面得學習。基本上可以簡單編寫socket通信和websocket通信
現在提出一個需求。要求websocket和socket進行通信
那麼這個怎麼進行思考呢?
1.首先需要讓兩種客戶端同時連接至服務器
2.進行通信
就這麼簡單
下面詳細得講解一下兩種方式如何同時連接一個服務端
首先基礎代碼
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace WebSocketCommunication
{
using System;
using System.IO;
using System.Net;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Codecs.Http;
using DotNetty.Common;
using DotNetty.Handlers.Tls;
using DotNetty.Transport.Bootstrapp