用socket// Input and output streams for TCP socket
protected DataInputStream in;
protected DataOutputStream out;
protected Socket connect (int port) throws IOException
{// Connect method
output.appendText ("\nConnecting to " + server + " Port " + port + "\n");
Socket socket = new Socket (server, port);
OutputStream rawOut = socket.getOutputStream ();
InputStream rawIn = socket.getInputStream ();
BufferedOutputStream buffOut = new BufferedOutputStream (rawOut);
out = new DataOutputStream (buffOut);
in = new DataInputStream (rawIn);
return socket; 
} // END connect=================
static Socket accept (int port) throws IOException {System.out.println ("Starting on port " + port);
// Setup ServerSocket
ServerSocket server = new ServerSocket (port);
System.out.println ("Waiting");
Socket ClientSocket = server.accept ();
// Extract the address of the connected user
System.out.println ("Accepted from " + ClientSocket.getInetAddress ());
server.close ();
// return the client sock so that communication can begin
return ClientSocket;

}