问题描述:
用ServerSocket写一个简单的服务器!但是为什么网页访问不了,代码如下:
- import java.io.*;
- import java.net.*;
- class ServerSocketDemo
- {
- public static void main(String[] args) throws Exception
- {
- ServerSocket ss = new ServerSocket(6789);
- Socket s = ss.accept();
- String IP = s.getInetAddress().getHostAddress();
- System.out.println(IP+"....connectde");
- BufferedWriter bufOut = new BufferedWriter(
- new OutputStreamWriter(s.getOutputStream()));
- bufOut.write("客户端你好");
- s.close();
- ss.close();
- }
- }
复制代码
这是什么原因呢?
|
|