Quic.NET
1.0.0
0x5C2AAD80
Quicnet是下面提到的QUIC协议的.NET实现。该实施与第32版的Quic-Transport草案一致,并且尚未提供以下相关草案的实施:
最小的示例
using System ;
using System . Text ;
using QuicNet ;
using QuicNet . Streams ;
using QuicNet . Connections ;
namespace QuickNet . Tests . ConsoleServer
{
class Program
{
// Fired when a client is connected
static void ClientConnected ( QuicConnection connection )
{
connection . OnStreamOpened += StreamOpened ;
}
// Fired when a new stream has been opened (It does not carry data with it)
static void StreamOpened ( QuicStream stream )
{
stream . OnStreamDataReceived += StreamDataReceived ;
}
// Fired when a stream received full batch of data
static void StreamDataReceived ( QuicStream stream , byte [ ] data )
{
string decoded = Encoding . UTF8 . GetString ( data ) ;
// Send back data to the client on the same stream
stream . Send ( Encoding . UTF8 . GetBytes ( "Ping back from server." ) ) ;
}
static void Main ( string [ ] args )
{
QuicListener listener = new QuicListener ( 11000 ) ;
listener . OnClientConnected += ClientConnected ;
listener . Start ( ) ;
Console . ReadKey ( ) ;
}
}
} using System ;
using System . Text ;
using QuicNet . Connections ;
using QuicNet . Streams ;
namespace QuicNet . Tests . ConsoleClient
{
class Program
{
static void Main ( string [ ] args )
{
QuicClient client = new QuicClient ( ) ;
// Connect to peer (Server)
QuicConnection connection = client . Connect ( "127.0.0.1" , 11000 ) ;
// Create a data stream
QuicStream stream = connection . CreateStream ( QuickNet . Utilities . StreamType . ClientBidirectional ) ;
// Send Data
stream . Send ( Encoding . UTF8 . GetBytes ( "Hello from Client!" ) ) ;
// Wait reponse back from the server (Blocks)
byte [ ] data = stream . Receive ( ) ;
Console . WriteLine ( Encoding . UTF8 . GetString ( data ) ) ;
// Create a new data stream
stream = connection . CreateStream ( QuickNet . Utilities . StreamType . ClientBidirectional ) ;
// Send Data
stream . Send ( Encoding . UTF8 . GetBytes ( "Hello from Client2!" ) ) ;
// Wait reponse back from the server (Blocks)
data = stream . Receive ( ) ;
Console . WriteLine ( Encoding . UTF8 . GetString ( data ) ) ;
Console . ReadKey ( ) ;
}
}
}QUIC是一种标准化的传输层协议,符合由Google设计的RFC 9000,旨在加快以连接为导向的Web应用程序的数据传输。该应用程序级协议的目的是通过使用多种技术类似于TCP传输,同时减少连接握手,并以一种可以在传输过程中交织不同的数据实体,从而从TCP转换为UDP。
连接是代表两个端点之间通信的第一个层次逻辑通道。建立连接后,两个端点之间会协商连接ID。连接ID也用于识别连接,即使在较低协议层上发生更改,例如电话更改Wi-Fi或从Wi-Fi切换到移动数据。该机制称为连接迁移,可防止重新启动谈判流和重新升级数据。
流是代表数据流的第二层逻辑通道。单个连接可以具有协商数量的流(例如8个最大值),这些流充当多路复用实体。每个流都有其自己的,生成的流ID,用于识别要传输的不同数据对象。当读取所有数据或达到协议的最大数据传输时,流都关闭。
数据包是数据传输单元。数据包标头包含有关该数据包被发送到的连接以及加密信息的信息。删除其他传输信息后,剩下的是数据框架(数据包可以具有多个帧)。
框架是最小的单元,其中包含需要将端点的数据或诸如握手谈判,错误处理等操作所必需的协议数据包进行。
遵循叉子并拉动github工作流程:
有关更多信息,请阅读贡献
如前所述,可以找到Quic-Transport草案。
要测试QUIC并查找其他信息,您可以访问与Quic一起玩。
可以在Proto-Quic上找到官方的C ++源代码。