Opening a port on Ubuntu 14.04 for communicating remotely with `DatagramSocket` client and Server

114 views Asked by At

I have two hosts one with Ubuntu 14.04 acting as server and other with windows 10 acting as client.Code in client side is as follows.

DatagramSocket socket = new DatagramSocket();
InetAddress destination = InetAddress.getByName("192.168.0.120");
DatagramPacket packet = new DatagramPacket(buffer,buffer.length,destination,50005);
socket.send(packet);

At server side:

DatagramSocket s = new DatagramSocket(50005);
DatagramPacket p = new DatagramPacket(receivedata,receivedata.length);
s.receive(p);

They both work fine under private network that is server is listening on port 50005 within private network.But replacing private address with public and accessing server isn't working.It's because port "50005" is closed.

How to port forward "50005" to my Ubuntu desktop where java server resides and make it accessible from anywhere on internet?

0

There are 0 answers