1.
客服端:浏览器(telnet)
服务端:自定义
2.
客服端:浏览器
服务端:TomCat服务器
3.
客服端:自定义
服务端:TomCat服务器
//例子如下:
import java.net.*; import java.io.*; class ServerDemo { public static void main(String[] args)throws Exception { ServerSocket ss = new ServerSocket(8080); Socket s = ss.accept(); System.out.println(s.getInetAddress().getHostAddress()); InputStream in = s.getInputStream(); byte[] buf = new byte[1024]; int len = in.read(buf); System.out.println(new String(buf,0,len)); PrintWriter out = new PrintWriter(s.getOutputStream(),true); out.println("<font color='read' 'size'=7>客户端你好</font>"); s.close(); ss.close(); } }