本帖最后由 woaiheima 于 2014-5-4 13:44 编辑
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class MyServer {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.out.println("服务器已启用");
ServerSocket ss=new ServerSocket(9090);
Socket s=ss.accept();
System.out.println(s.getInetAddress().getHostAddress());
InputStream in=s.getInputStream();
byte[] buf=new byte[4096];
int len=in.read(buf);
String text=new String(buf,0,len);
System.out.println(text);
PrintWriter out=new PrintWriter(s.getOutputStream(),true);
out.print("欢迎光临我的主页");
s.close();
ss.close();
}
}
-----------------------------------------------------------------------------------------------
我用IE和360浏览器访问都打不开,是怎么回事呢??
程序运行都是正常的.win8.1系统,JDK1.7
服务器已启用192.168.1.103GET /favicon.ico HTTP/1.1
Host: 192.168.1.103:9090
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8
Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3
|
|