Ale*_*lex 18 c++ java sockets cross-platform
I have a java application I need to pass some info to a C++ program. It has been suggested that I use some simple socket programming to do this. Is this the best way? If not what are the alternatives? If so, how should I go about learning about socket programming?
Dav*_*Ray 16
你有几个选择:
对于学习套接字,谷歌搜索"java套接字教程"或"c ++套接字教程"将为您提供大量信息.
一种简单的方法是使用标准输入和输出:
class MyTest {
public static void main(String... args) {
System.out.println("carpet");
}
} // Java
#include <iostream>
#include <string>
int main() {
string input;
std::getline(std::cin, input);
std::cout << "from java: " << input << std::endl; // output: carpet
} // C++
# start by piping java's output to c++'s input
$ java MyTest | ./my_receive
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5365 次 |
| 最近记录: |