HTTP Connection KeepAlive doesn't work!

Hello,

why the KeepAlive-Feature (reusing of TCP-connections, described at http://java.sun.com/j2se/1.5.0/docs/guide/net/http-keepalive.html) doesn't work in the following example? I'm using J2SE 1.4...

import java.net.HttpURLConnection;

import java.net.URL;

public class Test {

public static void main(String[] args) {

try {

for (int i=0; i<5; i++) {

URL url = new URL("http://www.sun.com/");

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setRequestMethod("GET");

conn.connect();

conn.getContent();

conn.disconnect();

}

} catch (Exception e) {

System.err.println("Exception: "+e.getMessage());

}

}

}

I've checked with Ethereal (http://www.ethereal.com), that 5 different TCP-connections are used, when this example runs.

Where is my mistake?

Does KeepAlive works with MIDP 1.0?

Slavik

[962 byte] By [slavslaa] at [2007-10-2 20:36:59]
# 1
may be conn.disconnect(); is closing the underlaying connection.Also try putting "Connection: keep-alive" header to the request
LRMKa at 2007-7-13 23:20:14 > top of Java-index,Core,Core APIs...