小编SEU*_*EUH的帖子

SslStream .read()以包的第一个字节返回

我想从我的SslStream中读取数据包.

我使用websocket发送数据包.此外,此功能在我完成WS握手后启动,因此它用于读取数据帧.

这是阅读的功能:

byte[] buffer = new byte[16 * 1024];
int read;
while (true) {
    read = input.Read(buffer, 0, buffer.Length);

    Console.WriteLine("Length: " + read + " Buffer: " + GetNumberOfSlotsUsed(buffer));

    if (read <= 0) {
        ...
    } else if (read < 3) {
        ...
    } else {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

一旦我收到一个数据包,这就是打印到控制台的内容:

Length: 1 Buffer: 1
Length: 57 Buffer: 57
Run Code Online (Sandbox Code Playgroud)

问题可能在这个函数中,还是发送数据包的浏览器?

我在用Java编写的Websocket服务器中使用"socket.read()"函数并没有问题,所以它必须是C#对吗?

编辑#1:

用于发送的Javascript代码:

var socket = new WebSocket(serviceUrl, protocol);
socket.onopen = function () {
    socket.send(omeString);
}
Run Code Online (Sandbox Code Playgroud)

c# sockets websocket

6
推荐指数
1
解决办法
1059
查看次数

标签 统计

c# ×1

sockets ×1

websocket ×1