c++ - 序列化 lua_State 以通过网络发送

标签 c++ networking lua serializable

我需要使用 C++ 中的套接字将 lua_state 发送到服务器。我如何序列化 lua_State 以便它可以通过网络发送?

最佳答案

根据您的需要,您有多种选择。您可以尝试使用 Pluto Library .它是一个“重量级”序列化库:

Pluto is a library which allows users to write arbitrarily large portions of the "Lua universe" into a flat file, and later read them back into the same or a different Lua universe. Object references are appropriately handled, such that the file contains everything needed to recreate the objects in question.

您也可以尝试 lper ,它使用 Linux Persistent Memory .

请注意,您在发送自定义 C 函数和用户数据时遇到问题...

如果你真的不需要发送整个lua_State(你为什么需要那个?),你可以看看TableSerialization Lua-users Wiki 上的页面。也许您可以通过发送包含您需要的整个“状态”的序列化(可能很大)Lua 表来解决您的问题。

关于c++ - 序列化 lua_State 以通过网络发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9216012/

相关文章:

c++ - 为什么要捕获异常作为对常量的引用?

C++ 三元组查找容器

.net - 如何将 GetType() 用于 CheckBox?

python - Pyshark不捕获任何数据包

lua - 为什么 Lua loadstring() 在演示站点上不起作用?

c++ - 无法连接到 SMTP 服务器

c++ - 使用 unix 套接字的同步 boost asio 中的延迟/延迟

c++ - 客户端服务器编程缓冲区内容不正确

android - 应用程序可以在模拟器上运行,但不能在安卓上运行

c++ - 如何获取从 C++ 发送到 Lua 函数的表的更新值?