套接字未通过移动网络连接

时间:2018-07-23 16:03:20

标签: java android

此代码遇到问题:

IPaddress = "35.176.220.47";
Port = 9999;
ClientSocket = new Socket(IPaddress,Port);
G.ConnectionLog[0] = "Connection to: "+IPaddress+"-"+Port;
InputStream in =ClientSocket.getInputStream();
BufferedWriter out = new BufferedWriter(new 
OutputStreamWriter(ClientSocket.getOutputStream()));
message ="string";
out.write(message);
out.flush();
byte[] m = new byte[2];
in.read(m);
out.close();
ClientSocket.close();

当设备通过Wifi连接时,它可以很好地完成工作,但是当我使用移动服务提供商时,它会遍历代码,但似乎没有例外。它也不会建立与服务器的连接。

0 个答案:

没有答案