DotNetty學習(六)——進階學習Socket和WebSocket互通

總覽鏈接:

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章