views:

344

answers:

3

hiho,

i intend to develop just a litte network application, something like a chat. so i downloaded xampp for windows and installed it (also as service), mysql included. well, i started the apache (and mysql) as service and just wrote the short line in java:

 try {
     Socket sock = new Socket("127.0.0.1", 21);
     System.out.println("connection established");
 } catch ( UnknownHostException e ) {
     System.out.println("Can't find host.");
 } catch ( IOException e ) {
     System.out.println("Error connecting to host. " + e.toString());
 }

but directly i got the answer:

Error connecting to host. java.net.ConnectException: Connection refused: connect

the server is runnin'. the localhost is accessible on the browser.

did i forgot something? any ideas?

A: 

In your java code you're trying to connect to port 21 (ftp). Don't know what you want to do, but perhaps you should try port 80 (http).

tangens
port 80 doesn't work. so i think, i need to check the configurations of that xampp..
mkind
A: 

Did you download and install the Tomcat add-on for XAMPP? It's not part of the default install.

After it's extracted into the XAMPP folder you have to run first setup_xampp.bat and then tomcat_start.bat.

Also, Tomcat in XAMPP will use the 8080 port by default.

A: 

how can i connect to my db created in xampp php my admin? im writing me code in eclipse java.. im beginer so if any one can help?

art