Can anyone tell me why this program hangs, it doesn't crash and it also doesn't throw an exception or anything, it just hangs. If I define the hostname and port inside the Connect class instead of in the constructor like I do now it doesn't hang. Is this a VM issue? I am testing this by using netcat as a server: nc -L -p 80 -vv .
public Connect(String host, int port) {
address = host;
PORTNUM = port;
}
void establishConnection() {
try {
socket = new Socket(address, PORTNUM);
isr = new InputStreamReader(socket.getInputStream());
reader = new BufferedReader(isr);
writer = new PrintWriter(socket.getOutputStream(), true);
} catch (IOException e) {
System.err.println("Exception: " + e.getMessage());
System.exit(1);
}
}
}
EDIT: I forgot to mention that it hangs upon clicking the Connect button, also, sorry for the lack of comments, well it's not that this piece of code really needs it but anyway.
August 6th, 2004, 05:51 PM
cgkanchi
Sorry, but I can't get it to emulate this behaviour. But then again I (obviously) don't have a crat server running anywhere. However, connecting to google on port 80 produced no hanging.
EDIT: Trying with netcat also did not reproduce the bug. Must be a VM issue. Get 1.4.2_03
Cheers,
cgkanchi
August 6th, 2004, 07:18 PM
el-half
Hehe, the server part is not yet usable.
Well I just declare the variables in the Connect class so it's not a big deal.
I have 1.4.2_01-b06, must be the VM indeed.
Crat stands for Crappy Remote Administration Tool by the way, this is the client as simple as possible and so is the server (still being programmed).