var Socket = plus.android.importClass("java.net.Socket");
var PrintWriter = plus.android.importClass("java.io.PrintWriter");
var BufferedWriter = plus.android.importClass("java.io.BufferedWriter");
var OutputStreamWriter = plus.android.importClass("java.io.OutputStreamWriter");
var BufferedReader = plus.android.importClass("java.io.BufferedReader");
var InputStreamReader = plus.android.importClass("java.io.InputStreamReader");
var socket = new Socket("192.168.1.251", 3333);
var outputStreamWriter = new OutputStreamWriter(socket.getOutputStream());
var bufferWriter = new BufferedWriter(outputStreamWriter);
var out = new PrintWriter(bufferWriter, true);
out.println("Conneted...");
var inputStreamReader = new InputStreamReader(socket.getInputStream());
var br = new BufferedReader(inputStreamReader);
console.log('br: ',br)
console.log('br.readLine(): ', br.readLine())
var msg = br.readLine();
console.log('msg: ', msg)
//while(true)
if(msg != null)
{
console.log(msg);
}
上面是按照社区的方法连接,但是死活连不上, msg 返回的null,提示连接超时
1***@qq.com
请问 ios 有这个原生的吗?
2019-12-02 11:51
柠檬茶的味道
楼主我也是 msg 返回的null,请问你解决了吗
2020-01-18 09:44
y***@vip.qq.com (作者)
回复 柠檬茶的味道: 之前是我的硬件设备问题,代码正常可以跑
2020-04-08 11:10