serversocket 堵塞
救命 救命
服务器端
package web;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
/**
*
* @author Administrator
*/
public class TcpServer {
/** Creates a new instance of TcpServer */
public TcpServer() {
}
public static void main(String[] args){
ServerSocket svesoc=null;
Socket soc=null;
InputStream is=null;
OutputStream os=null;
DataInputStream in=null;
PrintStream out=null;
try {
svesoc=new ServerSocket(8000,3);
svesoc.setSoTimeout(2000000);
soc=svesoc.accept();
is=soc.getInputStream();
os=soc.getOutputStream();
out=new PrintStream(os);
InetAddress clientIP=soc.getInetAddress();
System.out.println("Client''s IP address "+clientIP);
System.out.println("Client''s port "+soc.getPort());
out.println("welcome");
byte[] bmsg=new byte[1024];
补充:Jsp教程,Java基础