Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Background: I have written a java server-client program. The server accepts incoming connections on port 2175 and writes responses on 2176 which the client listens on for the response. I am sending serialzed objects over the network.

Problem: This all works well if I run my client on the same machine as the server. I put together a client jar and deployed it on another machine running on the same wireless network as the server. Now I get a "ConnectionException :Connection refused". So I thought I should hardcode the server and client IP's but that still didnt work.

Question: What else would I have to do to get the two computers to talk to each other (in terms of networking not java)?

share|improve this question

migrated from stackoverflow.com Jul 6 '12 at 15:39

This question came from our site for professional and enthusiast programmers.

    
As you note yourself, you're not looking for a programming answer, so you're on the wrong site. (Note that there are no forums on the Stack Exchange network). –  Mat Apr 11 '12 at 7:15

4 Answers 4

up vote 1 down vote accepted

If you are getting a connection refused you are able to talk to the machine, its just not listening on that IP address. Try opening the service on all IP addresses (e.g. by not specifying one)

BTW: You only need one port for sending and receiving.

share|improve this answer

First step, make sure the client is actually attempting to connect to the server's address ( check your code, clean, recompile). Next step, check you can ping the server from the client. Next step, check any firewalls, especially on the server machine, making sure that it allows incoming connections on port 2175. If all those things seem OK, check your router isn't blocking the connection (although that would be a bit strange). Wireshark or some other packet sniffer can help you diagnose the problem further.

share|improve this answer

Seem to be in client system port is closed or blocked or used by any other application. It does not depend on wire or wireless network all depends on open ports and which normally handled by firewall policy.

share|improve this answer

I had this problem too. I'm sure that the person who posted this problem was using Windows when he/she and deployed the server program. As I quoted earlier, the problem is with the Windows firewall. Yeah, it blocks everything else except the virus which it was intended to block. :P.

So, here's my solution for the problem. Deploy the server program in Ubuntu, if you don't have Ubuntu running on your machine, just install it on a Virtual machine which is what I'm doing currently. If you're running Windows 8.1 Pro, it comes with a built-in Virtual machine called Hyper-V.

All you have to do is

  1. Download Ubuntu OS and run(rather install) it through Hyper-V.
  2. Install Java on Ubuntu(which is running on Hyper-V).
  3. After Java is installed, get the IP address of the virtual machine running Ubuntu by typing "ifconfig" in the terminal. It has the format 192.168.x.x. So, that's your server IP.
  4. Now, run the client program on Windows and when you're trying to connect to the server, provide the IP address of the server(which you have just obtained by following the steps above) in your client program.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.