有没有好用些的工具?比如可以看在那个端口建立了监听,在那个端口发了什么数据?收了什么数据?JBuilder 7.0有没有内建的工具可用?

解决方案 »

  1.   

    一台机子:用java自带的java运行服务器端,用开发工具运行客户端,当然也可以反过来
    两台机子:不用我说你也知道吧
    其他方法还请大家补充!!
      

  2.   

    我在有两个程序,一个客户端的 ,一个的服务端。你分别试用就可以了
    服务端:
    //: JabberServer.java
    // Very simple server that just
    // echoes whatever the client sends.
    import java.io.*;
    import java.net.*;public class JabberServer {  
      // Choose a port outside of the range 1-1024:
      public static final int PORT = 8080;
      public static void main(String[] args) 
          throws IOException {
        ServerSocket s = new ServerSocket(PORT);
        System.out.println("Started: " + s);
        try {
          // Blocks until a connection occurs:
          Socket socket = s.accept();
          try {
            System.out.println(
              "Connection accepted: "+ socket);
            BufferedReader in = 
              new BufferedReader(
                new InputStreamReader(
                  socket.getInputStream()));
            // Output is automatically flushed
            // by PrintWriter:
            PrintWriter out = 
              new PrintWriter(
                new BufferedWriter(
                  new OutputStreamWriter(
                    socket.getOutputStream())),true);
            while (true) {  
              String str = in.readLine();
              if (str.equals("END")) break;
              System.out.println("Echoing: " + str);
              out.println(str);
            }
          // Always close the two sockets...
          } finally {
            System.out.println("closing...");
            socket.close();
          }
        } finally {
          s.close();
        }
      } 
    } ///:~
    客户端:
    addr, JabberServer.PORT);
        // Guard everything in a try-finally to make
        // sure that the socket is closed:
        try {
          System.out.println("socket = " + socket);
          BufferedReader in =
            new BufferedReader(
              new InputStreamReader(
                socket.getInputStream()));
          // Output is automatically flushed
          // by PrintWriter:
          PrintWriter out =
            new PrintWriter(
              new BufferedWriter(
                new OutputStreamWriter(
                  socket.getOutputStream())),true);
          for(int i = 0; i < 10; i ++) {
            out.println("howdy " + i);
            String str = in.readLine();
            System.out.println(str);
          }
          out.println("END");
        } finally {
          System.out.println("closing...");
          socket.close();
        }
      }
    } ///:~