日期:2014-05-20 浏览次数:20718 次
package com.cn.socket; import java.io.DataOutputStream; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; public class TCPClient { public static void main(String[] args) throws UnknownHostException, IOException { String name; String password; String email; Scanner sc = new Scanner(System.in); System.out.println("输入name:"); name = sc.nextLine(); System.out.println("输入password"); password = sc.nextLine(); System.out.println("输入email"); email = sc.nextLine(); Socket s = new Socket("127.0.0.1", 4444); DataOutputStream dos = new DataOutputStream(s.getOutputStream()); dos.writeUTF(name + "&" + password + "&" + email); s.close(); } }