How to enable ports on a wireless network for java socket programming

0

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

sachinrahulsourav

Posted 2012-04-11T07:09:40.530

Reputation:

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 – 2012-04-11T07:15:35.633

Answers

1

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.

Peter Lawrey

Posted 2012-04-11T07:09:40.530

Reputation: 146

1

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.

user1309663

Posted 2012-04-11T07:09:40.530

Reputation:

0

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.

Subhrajyoti Majumder

Posted 2012-04-11T07:09:40.530

Reputation: 101

0

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.

Gautham Bangalore

Posted 2012-04-11T07:09:40.530

Reputation: 1