基于socket的类msn系统,我刚做的,由socket server和applet client组成。可以提供设计文档(rose file),和一些基本代码(sorry for no complete code)如果需要,留你的email

解决方案 »

  1.   

    thank you .give me please. [email protected]
      

  2.   

    I also want.
    [email protected]
      

  3.   

    也能给我一份吗?
    [email protected]
      

  4.   

    请问 chenyuan_tongji  :    如何通过服务器转接实现两个socket客户端之间的通信?
      

  5.   


     thinforg001(瘦青蛙) :我给你留短信了
      

  6.   

    client端的unique标志解决方法很多呢
    比如某个client第一次和server交互的时候,server为其产生一个client key,保存在数据结构里面,和处理该client的thread匹配;总之,你自己东东好好想想肯定会有解决知道的,方法都是人想出来的,好不好是另外一回事,先解决问题。我也不知道自己的solution是不是规范,但是目前看,效果不错,就是这样。
      

  7.   

    随便给个例子就成。我java用的不是很多,所以里面都什么可以用我实在不清楚。
    戏可以自己演,但是道具你得给我呀。
      

  8.   

    谢谢您啊!
    也给我一份![email protected]
      

  9.   

    to: chenyuan_tongji谢谢您啊!
    也给我一份![email protected]
      

  10.   

    一个 ServerSocket 只能和一个客户端建立连接.
    可以用多线程建立多个ServerSocket处理多客户.
      

  11.   

    [email protected]
    我想要,谢谢
      

  12.   

    import java.net.*;
    import java.io.*;public class MyServer extends Thread
    {
    protected MyClient[] clients;
    protected int maxnum;
    protected int number;

    public MyServer(int num) {
    this.maxnum = num;
    clients = new MyClient[this.maxnum];
    } public static void main(String[] args) {
    MyServer myServer = new MyServer(20);
    myServer.start(); // add your GUI code here;
    // when you want send message to all client, invoke sendAll(); myServer.stop();
    } public void run() {
    try {
    int port = 80;
    ServerSocket ss = new ServerSocket(port);
    while (true) {
    Socket client = ss.accept();
    if (number < maxnum) {
    clients[number] = new MyClient(client);
    number++;
    }
    else {
    System.out.println("Get the Max Thread");
    }
    }
    } catch (Exception e) {
    System.out.println(e.toString());
    }
    } public void sendAll(String msg) {
    int i, j=0;
    for (i=0; i<maxnum; i++) {
    if (clients[i] != null) {
    clients[i].sendMessage(msg);
    j++;
    }
    }
    System.out.println("Message send to " + j + " client!");
    }
    }class MyClient{
    Socket client;
    BufferedReader in;
    PrintWriter out; MyClient (Socket s) {
    clie nt = s;
    try {
    in = new BufferedReader(new InputStreamReader(client.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
    } catch (Exception e) {
    System.out.println(e.toString());
    }
    } public void sendMessage(String msg) {
    out.println(msg);
    out.flush();
    }
    };一个简单的例子,还有许多问题,你可以参考一下。
      

  13.   

    import java.net.*;
    import java.io.*;public class MyServer extends Thread
    {
        protected MyClient[] clients;
        protected int maxnum;
        protected int number;
        
        public MyServer(int num) {
            this.maxnum = num;
            clients = new MyClient[this.maxnum];
        }    public static void main(String[] args) {
            MyServer myServer = new MyServer(20);
            myServer.start();        // add your GUI code here;
            // when you want send message to all client, invoke sendAll();        myServer.stop();
        }    public void run() {
            try {
                int port = 80;
                ServerSocket ss = new ServerSocket(port);
                while (true) {
                    Socket client = ss.accept();
                    if (number < maxnum) {
                        clients[number] = new MyClient(client);
                        number++;
                    }
                    else {
                        System.out.println("Get the Max Thread");
                    }
                }
            } catch (Exception e) {
                System.out.println(e.toString());           
            }
        }    public void sendAll(String msg) {
            int i, j=0;
            for (i=0; i<maxnum; i++) {
                if (clients[i] != null) {
                    clients[i].sendMessage(msg);
                    j++;
                }
            }
            System.out.println("Message send to " + j + " client!");
        }
    }class MyClient{
        Socket client;
        BufferedReader in;
        PrintWriter out;    MyClient (Socket s) {
            clie nt = s;
            try {
                in = new BufferedReader(new InputStreamReader(client.getInputStream()));
                out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
            } catch (Exception e) {
                System.out.println(e.toString());
            }
        }    public void sendMessage(String msg) {
            out.println(msg);
            out.flush();
        }
    };重贴一个,希望csdn能自动将"/tab"转化为"4space"
      

  14.   

    谢谢给我一份,
    [email protected]