- package Myserver;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.PrintWriter;
- import java.net.ServerSocket;
- import java.net.Socket;
- public class Server {
- public static void main(String[] args) throws IOException{
- ServerSocket ss = new ServerSocket(8080);//报错不知道啥意思
- Socket s = ss.accept();
- System.out.println(s.getInetAddress().getHostAddress()+"........connected");
-
- InputStream in = s.getInputStream();
- byte[] buf = new byte[1024];
-
- int len = in.read(buf);
- String str = new String(buf,0,len);
- System.out.println(str);
-
- PrintWriter out = new PrintWriter(s.getOutputStream(),true);
- out.println("<font size='7' color='red'>欢迎光临</font>");
-
- s.close();
- ss.close();
- }
- }
复制代码 报错是at java.net.ServerSocket.<init>(ServerSocket.java:97) at Myserver.Server.main(Server.java:11)
|