如何发送或保存一个函数,recv或恢复一个函数并在C ++中执行它? [英] How do I send or save a function and recv or restore a function and execute it in C++?

查看:147
本文介绍了如何发送或保存一个函数,recv或恢复一个函数并在C ++中执行它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以发送或保存一个函数作为文件?我想在Windows平台上使用C ++。

Is there any way I can send or save a function as file? I want to do this in C++ on a Windows platform.

我假设读写器和发送器或保存器之间有一些约定。

I assume that there is some convention between reader and sender or saver

如果我发送像下面是好吗?
服务器端:

Is it OK if I send like below? server side:

label1:
int func1(int somevar){
    int a = 1;
    return somevar+a;
}
label2:

send(sockfd, label2-label1, sizeof(int), 0) //send a size first
send(sockfd, label1, label2-label1, 0); // send a "function" 

提前感谢!

推荐答案

不,没有办法在C + +。可传递可执行代码的语言包括Erlang,Ruby,TCL。

No, there's no way to do that in C++. Languages which could allow transfer of executable code include Erlang, Ruby, TCL.

Chris

这篇关于如何发送或保存一个函数,recv或恢复一个函数并在C ++中执行它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆