• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

How to make LAN chat working over INTERNET

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I wrote a chat application, client+server using sockets. The problem is that I have to make it comunicate over internet and it's working only over LAN. I disabled my firewall, I verified my address to be public BUT I cannot make it work over internet. What's the problem? If I connect the client to my local IP, ok. If I try to connect it to my public or someone else computer my public IP, it's not working. "Connection is refuzed"
I need this so much! Please help if you can! My application should send files over internet between the two computers. I tried all these days...
 
author
Posts: 23937
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is really no difference between a LAN and a WAN in this regard. Two computers simply talk via a socket, that are connected using IP addresses as targets. So, your chat program should work regardless of it being a local network versus the internet.


So... what is the difference? Generally, no one places a computer directly on the internet anymore. Instead, they use a router, which creates a private network, and all the computers in the house are behind it. This means that no one on the internet sees your computer -- they only see the router. This is used to protect your home computer from bad people on the internet. So... how to do this?

If both computers are directly on the internet, then it should work unchanged.

If one computer is on the internet, and the other is behind a router, then the computer behind the router must be the one that initiates all the connections -- as the computer directly on the internet can't see the computer behind the router.

If both computers are on the router, then it gets a bit harder. First, you need to configure your router to port forward to your computer behind the router -- basically, if someone on the internet tries to connect to your router at a particular port, it will be routed to your computer at the same or different port. Second, from the other computer, you can try to connect to the first computer by connecting to the first computer's router -- which will be forwarded.

Henry
 
claudiu teodorescu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply, Henry.
My computer which would run the server application is behind a router (ASUS). I don't know how to forward the port. The other computer (a friend) runs the client and I don't think he has a router... but however I will take your advices.
I must add that I tried to run the server and client both on my computer and connect the client to my public address. If the port was forwarded the connection should be entablished?
Now as you know exactly the situation can you tell me how to forward the port? And should I disable my antivirus and firewall or add the forwarded port as "trusted"?

Thanks,

Claudiu
 
Henry Wong
author
Posts: 23937
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

claudiu teodorescu wrote:Now as you know exactly the situation can you tell me how to forward the port?



This completely depends on your router. You need to log into your router to configure it. And the administration screens are different for different products. To connect to the router though, is generally done by using a browser to log in.

Also, if you are using DHCP, you may also want to configure your server with a static IP address -- depending if the port forwarding menu, ask for an IP address or not (some are smart enough to need only a mac address).


claudiu teodorescu wrote:And should I disable my antivirus and firewall or add the forwarded port as "trusted"?



Well, if you are going to go through the trouble of port forwarding at the router, only to have your server block the connection, that kinda defeats the purpose, doesn't it?

Henry
 
claudiu teodorescu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made my ip static. And tried to forward the port.. see the images... I don't know if I made it well... all I know is I cannot connect the client to server yet. It's working in LAN. Thanks for interest in helping me


 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey I've been working on a similar program. I configured my router to forward to my computer and the program connects through the router's ip address, which works when i run it at home but my friend who is not behind a router could not connect, any tips?
 
claudiu teodorescu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeap... I could connect by forwarding the port on my router.... but when I try from a friend... (with no router) I cannot connect to him (he would be the server who initiates the connection). Don't know why... try tell your friend so close all the firewalls and try again...
 
Sheriff
Posts: 22742
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

claudiu teodorescu wrote:try tell your friend so close all the firewalls and try again...


Then tell him to smack you in the head for suggesting a solution that ends up with his PC being hacked and flooded in viruses.

If you think I'm kidding, sadly not. If you connect an unprotected Windows machine directly to the Internet that PC is bound to be hacked and/or infected within half an hour, without even doing anything like opening a web browser. The cause is that many of the Windows services (like RPC, NetBIOS, etc) are enabled, unsafe and easily target / infected. Viruses like Blaster can and will infect a PC within mere minutes.

He should check his firewall though, and see if it is blocking any unknown traffic. He should only allow what needs to be allowed.
 
Do Re Mi Fa So La Tiny Ad
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic