tags:

views:

58

answers:

1

I have small test app:

Socket socket = new Socket("jeck.ru", 80);

PrintWriter pw = new PrintWriter(socket.getOutputStream(), false);
pw.println("GET /ip/ HTTP/1.1");
pw.println("Host: jeck.ru");
pw.println();
pw.flush();

BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream()));

String str;
while ((str = rd.readLine()) != null) {
    System.out.println(str);
}

It`s output:

HTTP/1.1 200 OK
Date: Sat, 13 Mar 2010 22:06:51 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=5
Server  HTTP/1.1 200 OK
Date: Sat, 13 Mar 2010 22:06:51 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=5
Server: Apache
Cache-Control: max-age=0
Expires: Sat, 13 Mar 2010 22:06:51 GMT

123
<!DOCTYPE html>
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Ваш IP</title>
</head>

<body>
        <div style='text-align: center; font: 32pt Verdana;margin-top: 300px'>
        Ваш IP &#151; 94.103.87.153     </div>
</body>
</html>

0

Whence these numbers (123 an 0) takes?

+3  A: 

These numbers are a result of:

Transfer-Encoding: chunked

See Chunked transfer encoding for more details and links to specifications.

Greg Hewgill