从c++代码与servlet交互
Interacting with a servlet from a C++ code
你好,我正在尝试从c++代码调用java servlet。到目前为止,我已经得到了这个:
execl( "/usr/bin/lynx", "lynx", "-dump", url.c_str(), (char *) 0);
其中"url"是url编码的字符串,包含地址和参数。
然而,我还没有找到一种方法来让execl返回servlet响应,以便我在代码中分析它。是否有一种更有效的方法来调用servlet并处理答案?
谢谢!
您可以使用pipe:
string cmd = "lynx -dump ";
cmd += url;
FILE* pipe = popen(cmd.c_str(), "r");
if (!pipe)
{
cout << "Couldn't open pipe";
return;
}
char buffer[128];
string result = "";
while(!feof(pipe))
{
if(fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
pclose(pipe);
相关文章:
- Qt VTK交互风格的信号到小部件
- Qt Quick-如何仅从c++代码与qml属性交互
- 复制和交换习惯用法与移动操作之间的交互
- 为什么在访问 vtkRenderWindow 的"交互器"变量时会发生段错误?
- Qt QGraphicsProxyWidget 与 QGraphicsScene 的交互
- 使用 Python 事件并与 C++ 交互
- 函数-本地枚举声明和 ADL 的交互
- 如何在扩展的QQuickItem中与模型交互
- 寻找C++中数组和cout交互的解决方案
- C++继承和"常量"交互的问题
- 以太坊与外部 c++ 库的交互稳定性
- 玩家移动和碰撞之间的交互问题
- C++ 和 Lua 函数之间的交互与 3D 矢量参数
- 内存分配究竟是如何发生的,Java和C如何交互以跟踪同一对象?
- 如何包装对象,使它们成为无法交互的单独类型?
- 通过交互器获取向量中的索引
- 如何在python中的PyArrow和C++中的Arrow之间进行交互时将PyArrow表转换为Arrow表
- 检测屏幕上的坐标是否可交互
- 如何在不中断整个循环的情况下跳过循环交互 - C++
- 从c++代码与servlet交互