This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Socket & NAT technologie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Socket & NAT technologie" Watch "Socket & NAT technologie" New topic
Author

Socket & NAT technologie

ouadie lahdioui
Greenhorn

Joined: Feb 23, 2012
Posts: 1

Hi EveryOne ,
I need to create a programme based on JAVA Socket , thts normal !
but my client connected behind a router , i mean tht is use NAT Technologie to connect to Internet .
can somme one Help me ?



Ouadie
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Your Java program doesn't know or care about the NAT. You write your code exactly the same way as if there was no NAT.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18876
    
  40

ouadie lahdioui wrote:Hi EveryOne ,
I need to create a programme based on JAVA Socket , thts normal !
but my client connected behind a router , i mean tht is use NAT Technologie to connect to Internet .
can somme one Help me ?



Please search for previous topics -- as this question has come up before.

Basically, if your client (who is behind the router) is the socket initiator, you should have no problems. However, if the client is the socket acceptor, then (1) you need your server to connect to the router instead of the client machine, and (2) you need to configure the router to forward the particular port to the client machine.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
GeeCON Prague 2014
 
subject: Socket & NAT technologie