Java, sockets, BufferedReader, and readline hang … :(

后端 未结 3 1262
半阙折子戏
半阙折子戏 2020-12-03 19:12

I\'m not a Java programmer at all. I try to avoid it at all costs actually, but it is required that I use it for a class (in the school sense). The teacher requires that w

3条回答
  •  一个人的身影
    2020-12-03 19:39

    Your HTTP request is not complete without 2 carriage return + linefeed pairs. You should probably also call close after the request is sent:

    out.print("GET /index.html HTTP/1.0\r\n");
    // maybe print optional headers here
    // empty line
    out.print("\r\n");
    out.flush();
    out.close();
    

提交回复
热议问题