总览链接:
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.Bootstrapping;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Sockets;
using DotNetty.Transport.Libuv;
public class Program
{
public static async Task RunServerAsync()
{
bool useLibuv = true;
Console.WriteLine("Transport type : " + (useLibuv ? "Libuv" : "Socket"));