Very slow socket execution

I am getting very slow socket initialization. Here is sample code to clarify the issue. I suspect is has to do with reverse lookups or some such thing - is there a way to disable all of that? I tried using the security manager but that is a bad solution because it does not seem doable from within the program - which means it will be slow for users even if I can make it fast for a developer.

public String ExchangeStringWithNet(String Host, Integer Port, String Content) // Send Content to Host on Port - Get back response (send a string - get a string - deal done)

{PrintWriter out;BufferedReader in;Socket socket;

int SleepTime=100;

try {

InetAddress zz = InetAddress.getByName("74.95.10.172");System.out.println("set " + zz);

zz = InetAddress.getByName("all.net");System.out.println("set " + "all.net " + zz);

socket = new Socket(zz, Port);System.out.println("Go");socket.close();

socket = new Socket(zz, Port);System.out.println("Go2");socket.close();

socket = new Socket(zz, Port);System.out.println("Go3");

socket.setSoTimeout(SleepTime);

out = new PrintWriter(socket.getOutputStream(), true);

in = new BufferedReader(new InputStreamReader(socket.getInputStream()));}

catch (UnknownHostException e) {JOptionPane.showMessageDialog(p, "Unknown host: " + Host + ":" + Port + " - Try again later");return("");}

catch (IOException e) {JOptionPane.showMessageDialog(p, "No I/O available with host " + Host + ":" + Port);return("");}

out.println(Content);

String result="";

while (true)

try{line = in.readLine();if (line == null) {System.out.print(".");try{in.close();out.close();socket.close();}

catch (IOException f) {}; return(result);} else result = result + line + "\n";}

catch (IOException e) {JOptionPane.showMessageDialog(p, "Read failed in exchange with " + Host + ":" + Port + " - Please retry later");

try{in.close();out.close();socket.close();} catch (IOException f) {};return(result);}

}

[2061 byte] By [fcatallneta] at [2007-11-15]
# 1

Are you running JDK 1.5? See reply 22 here:

http://forum.java.sun.com/thread.jspa?threadID=666921&start=15&tstart=0

sjasjaa at 2007-7-28 > top of java,Core,Core APIs...
# 2

OSX version 1.5.0_07

I have tried each of the 7-8 solutions identified in the URL provided and several URLs linked from there - none do the job. This bug seems to remain even though it is claimed to be fixed. As far as I can tell there is no later version than the one I am running - I have the most recent update to java from Apple as of a few days ago.

Any other suggestions?

fcatallneta at 2007-7-28 > top of java,Core,Core APIs...