Comments (9)
如果你了解MQTT那应该很容易,可以看一下samples如何操作网络数据流。
https://github.com/IKende/FastHttpApi 这个http服务也是BeetleX的基础上进行构建的
from beetlex.
您好,我用sample里面的例子 使用工具测试为啥在server端收不到数据呢?是发送数据格式不对 还是怎么回事。谢谢
from beetlex.
那个sample ,发怎样的数据?
from beetlex.
Echo.Server 用你介绍的TCP/UDP服务性能测试工具 发一段utf文本,server收不到,用Echo.Client 随便发什么都可以接收到,不过好像有长度限制
from beetlex.
我的意思是在这里不能输出:
public override void SessionReceive(IServer server, SessionReceiveEventArgs e) { string name = e.Stream.ToPipeStream().ReadLine(); Console.WriteLine(name); e.Session.Stream.ToPipeStream().WriteLine("hello " + name); e.Session.Stream.Flush(); base.SessionReceive(server, e); }
from beetlex.
ReadLine(),有回车符的才能read出数据
from beetlex.
我试试看 谢谢
from beetlex.
先关注下
from beetlex.
在非HTTP传输环境下,传string可以把长度前置,类似WCF传string 的有一长度编码算法我觉得可以借鉴下
`
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
int _byteCount = System.Text.Encoding.UTF8.GetByteCount("ABCDEFG");
var _intEncodeSize = GetEncodedSize(_byteCount);
var _intEncode = Encode(_byteCount, _intEncodeSize);
var _dCount = Decode(_intEncode, 0, _intEncode.Length);
}
public static byte[] Encode(int byteCount, int size)
{
var bytes = new byte[size];
var offset = 0;
while ((byteCount & 0xffffff80L) != 0)
{
bytes[offset++] = (byte)((byteCount & 0x7f) | 0x80);
byteCount = byteCount >> 7;
}
bytes[offset] = (byte)byteCount;
return bytes;
}
public static int GetEncodedSize(int value)
{
int _num = 1;
while ((value & 0xffffff80L) != 0)
{
_num++;
value = value >> 7;
}
return _num;
}
public static int Decode(byte[] buffer, int offset, int size)
{
int num = 0;
int value = 0;
int index = 0;
bool isValueDecoded = false;
while (num < size)
{
int num2 = buffer[offset];
value |= (num2 & 0x7f) << (index * 7);
num++;
if ((index == 4) && ((num2 & 0xf8) != 0))
{
throw new Exception();
}
index = (short)(index + 1);
if ((num2 & 0x80) == 0)
{
isValueDecoded = true;
return value;
}
offset++;
}
return value;
}
}`
这个算法会根据字符长度选择最少的byte位数去记录长度。读到长度后再去读后面的string内容
from beetlex.
Related Issues (20)
- BeetleX.Buffers.PipeStream Write 获取buffer偶尔为null HOT 5
- Upgrade to Websocket seems to be broken HOT 1
- AsyncTcpClient 接收不到Disconnected事件 HOT 1
- 能不能保持代码版本同步? HOT 2
- 请问一下呢 HOT 1
- 怎么设置时间呢 HOT 5
- 请问一下,耗时操作 HOT 1
- 内存池用完了,怎么处理? HOT 1
- 服务端发送大文件会丢失4096字节
- server very slow after 5min HOT 1
- TCP merged packets HOT 3
- BeetleX 1.8.0.2 issues about client HOT 1
- 免费版本 (并发响应数: 100) HOT 1
- 一个封锁操作被对 WSACancelBlockingCall 的调用中断 HOT 6
- 将FastHttpAPI的BeetleX的库调整最新的,图片文件等资源会出错 HOT 1
- 升级到net6或者net7 HOT 2
- TCP client certificate can't be added HOT 2
- WriteUTF咨询 HOT 4
- Async TcpClient ethernet cable disconnected not detected
- 10 consecutive accept failures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beetlex.