服务器反推技术,flex flash socket java javascript
http://hi.baidu.com/wenliang86/blog/item/844cbfca626ae29ac8176876.html 感谢大家的回答: 问题已经解决了: 如下: 服务器代码: package JSocket; ? ? import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; ? public class Server { private static final int PORT = 3000; // 端口号 private static List<Socket> list = new ArrayList<Socket>(); // 保存连接对象 private ExecutorService exec; private ServerSocket server; ? public static void main(String[] args) { new Server(); } public Server() { try { server = new ServerSocket(PORT); exec = Executors.newCachedThreadPool(); System.out.println("服务器已启动!"); Socket client = null; while (true) { client = server.accept(); // 接收客户连接 list.add(client); exec.execute(new ChatTask(client)); } } catch (IOException e) { e.printStackTrace(); } } ? static class ChatTask implements Runnable { private Socket socket; private BufferedReader br; private String msg=""; private String msg1=""; ? public ChatTask(Socket socket) throws IOException { this.socket = socket; br = new BufferedReader(new InputStreamReader(socket.getInputStream())); } ? public void run() { new Thread(new Runnable() { public void run() { PrintWriter pw; try { pw = new PrintWriter(socket.getOutputStream(),true); int i=0; while(true){ msg="<cross-domain-policy><allow-access-from domain="" + "*" + "" to-ports="3000"/></cross-domain-policy> |