- public class BrowserServer {
- public static void main(String[] args) {
- ServerSocket ss = null;
- try {
- ss = new ServerSocket(8888);
- } catch (IOException e) {
- System.out.println("服务器端Socket创建失败!");
- }
- Socket s = null;
- try {
- s = ss.accept();
- } catch (IOException e) {
- System.out.println("获取客户端Socket对象失败!");
- }
- try {
- PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
- pw.println("哦我的天啊!");
- } catch (IOException e) {
- System.out.println("获取网络输出流失败!");
- }
-
- }
- }
复制代码 为什么我在浏览器地址栏中输入:http://(本机IP):8888之后,显示连接失败呢??
按理说应该显示 “哦我的天啊”才对啊... |
|