我正在尝试将我的'Galaxy S'连接到我的Panasonic PLC(甚至其他PC本身),但我总是得到一个SocketTimeoutException。我的Android版本是2.3.3:
IP-PLC:192.168.2.99
IP-GalaxyS:我不知道怎么检查
网络掩码:255.255.255.0
PLC直接与Wi-Fi路由器连接,我将手机连接到该网络。
package com.example.communication;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import android.util.Log;
public class TryConnection implements Runnable {
public void run() {
try {
InetAddress serverAddr = InetAddress.getByName("192.168.2.99");
Socket socket = new Socket(serverAddr, 9094);
Log.e("SUCESS", "SUCESS");
} catch(SocketTimeoutException e) {
Log.e("SOCKET TIMEOUT", "SOCKET TIMEOUT", e);
} catch (IOException e) {
Log.e("CONNECTION ", " ERROR", e);
}
}
和我的MainActivity类:
package com.example.communication;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendTag(View view) {
TryConnection tryconnection = new TryConnection();
Thread thread = new Thread(tryconnection);
thread.start();
}
}
你知道为什么会这样吗?
答案 0 :(得分:0)
它也发生在我身上,重启eclipse以解决问题。