开发者

xampp server and java client/server application

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开发者_Go百科.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?


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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜