初学
这个程序为何会崩安卓端:
package com.example.client;import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;public class MainActivity extends Activity
{ @Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

try
{
Socket client = new Socket("192.168.1.100", 30000);
} catch (UnknownHostException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
} @Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}}
电脑端:
import java.io.IOException;
import java.net.ServerSocket;
public class Server
{ /**
 * @param args
 * @throws IOException 
 */
public static void main(String[] args) throws IOException
{
// TODO Auto-generated method stub

ServerSocket server = new ServerSocket(30000);
while(true)
{
System.out.println("waiting client!!!");
server.accept();
System.out.println("client has been linked!!!");
} }}