android socket编程时 客户端接受不到服务器的信息?

代码如下:
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main(String[] args) {
System.out.println("服务器");
try {
ServerSocket server = new ServerSocket(8888);
while(true){
Socket client=server.accept();
OutputStream out=client.getOutputStream();
String msg = "Hello Android!";
out.write(msg.getBytes());
client.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

package com.example.my_client;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView myTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

myTextView = (TextView)findViewById(R.id.msgTextView01);
try {
Socket socket = new Socket("192.168.1.101",8888);
InputStream in = socket.getInputStream();
byte[] buffer = new byte[in.available()];
in.read(buffer);
String msg = new String(buffer);
myTextView.setText(msg);
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
我以前 也遇到过这问题啊。、、、、、后来知道了。

原因:手机和电脑不在一个网络里

我当时是这么解决的。。。。。。装了个HTC Sync

手机和电脑网络同步。。完美解决。。。。了