> well i dont rly have an error, but i dont know how to
> make it accessable from computers not linked to the
> network.
If there is no linkage then there can be no commnication - period.
Perhaps you are referring to the internet (or less likely a Wan). The computer that is connecting MUST have access to the IP it is connecting to. That means, for the internet, then you MUST have a public IP.
What kind of internet connection do you have? If you are behind a router with a public IP then connect to it (try 192.168.1.1 - or something else depending on the make) and setup port forwarding for specific ports to your computers private ip. Now others can connect to your computer using the public ip address of your router as long as they connect to the ports that you specified for forwarding.
> Hey, i looked online at stuff, and i saw that because
> computers that i use use a private ip, i need to mess
> with some NAT and subnet mask thing to get it to
> work. can someone point me on someway i can do the
> whole private to public ip thing with the NAT stuff?
> (maybe i have it backwards).
I already told you, you MUST have a public IP.
What you read above is referring when YOU control the routers and network. Then your network cloud HAS a public IP. So you can set up forwarding so that it works.
Do you control the network at your school? Does your school even have a public IP?
Do you have a public IP at home on the router that connects to your broadband ISP?
> hmm i'm a bit confused; i thought that to connect to
> the net u needed an ip (private ip 4 the local
> network, but it all plugged into the router which had
> a public ip).
There is a server (connect to) and a client(connect from).
To connect to something on the internet the something must have a public IP.
You have a chat server. That means for a client to connect to it via the internet the server must have a public IP.
hello
if your router is connected to the internet you have 2 choices:
first with adress translation (nat) you can set up your router to bring the request to a specified server and a specified port
for example if your public ip is 82.156.23.23 , your application port is 80 and your serveradresse is 192.168.0.1
you can translate i83.156.23.23:80 into 192.168.0.1:80
the second method is to configure a dns...
+++
> hello
>
> if your router is connected to the internet you have
> 2 choices:
> first with adress translation (nat) you can set up
> your router to bring the request to a specified
> server and a specified port
> for example if your public ip is 82.156.23.23 , your
> application port is 80 and your serveradresse
> is 192.168.0.1
> you can translate i83.156.23.23:80 into
> 192.168.0.1:80
>
> the second method is to configure a dns...
This is absolutely pointless if the person is not in control of the network equipement. And a public IP must still exist.
For many people the above would require that their ISP would have to do something. And it isn't likely that is going to happen.
> don't worrry man we are exactly in the same situation
> but i've just solve the problem 3 days
> ago
>
> in order to configure the nat you have to refer your
> router's documentation
> you can usually find a webinterface at
> http://ip_adr_of_the_router
>
>
And that works because your router has a public IP. Which means you have a public IP.
It is absolutely worthless, and very confusing, to someone who does not have a public IP.
> i think i understand the concept of it, but how do i
> do address translation? how do i translate the ip to
> the private ip? and what is dns configuratin? sorry
> i'm noob at this, i'm just trying to learn.
Again....the discussion of NAT is useless unless you have a public IP.
You might have public IP and be unaware of it. If so the IP (ISP side) will have a public IP.
There are probably many places in the world where you will only have a public IP if you made specific arrangements with your ISP. In the US it will probably be universally true that any home setup will not have a public IP unless you are paying extra to your ISP.
> In the US it will
> probably be universally true that any home setup will
> not have a public IP unless you are paying extra to
> your ISP.
Not completely accurate. Home setups typically have a public IP assigned by the ISP. The ISP can reassign a different public IP at any time, i.e. the IP is dynamic. The more correct statement is that home setups typically do not have a static public IP.
> hey, i'm making a mini chatserver thing, and i've
> gotten it to work on the local network, but i was
> wondering if i could extend it to beyond the local
> network. is it possible to do this with j2se?
OP, which local network are you referring to? Is this your own local network at home? Or is it the local network at school?
You can certainly use your home computer to have some third party connect to your application. I do this all the time. The problems with this are:
1) You don't have a domain name at home. Which means you can only use your home computer's IP address.
2) most ISP's allocate IP addresses dynamically. At any time the ISP may reassign a different IP address to your machine at home.
3) You must find out what your current IP address is. You can do this on Windows by opening a command prompt and running the ipconfig command. You then give this IP address to the external third party.
4) If your ISP reassigns a new IP address, the third party will no longer be able to connect. You will have to find the newly assign IP address and again provide it to the third party.
5) Of course, your system must remain up and running and connected to the Internet for the third party to be able to connect.
The discussion about NAT assumes the local network you refer to is the typical company local network. If your project is for school, your school should have provided you with an account in a lab computer that you can use to deploy your application. You need to talk with your school's lab assistants if this is the case.
-o-
> > In the US it will
> > probably be universally true that any home setup will
> > not have a public IP unless you are paying extra to
> > your ISP.
>
> Not completely accurate. Home setups typically have a
> public IP assigned by the ISP.
Exactly what part of the US are you referring to?
Where I am, every single ISP requires that the user request a public IP and all assess an additional fee for that.
> The ISP can reassign a
> different public IP at any time, i.e. the IP is
> dynamic. The more correct statement is that home
> setups typically do not have a static public IP.
I understand exactly the difference between public and static IPs. I meant exactly what I said.
Um, I'm still not sure exactly what you want to know, but the general process for running a server on a network behind a router is:
-Run the program, determine what port it runs on
-Forward the port on your router
You know how to forward ports, yeah? Okay. You looking for the code to accept connections as a java server?
import java.io.*;
import java.net.*;
public class Server
{
public static void main(String[] args)
{
int port = 4444; //whatever port you want to use(forward on your router)
PrintWriter out;
try
{
ServerSocket server = new ServerSocket(port);
System.out.println("Now listening on "+port+".");
while(true)
{
Socket socket = server.accept();
out = new PrintWriter(
new OutputStreamWriter(
socket.getOutputStream()));
//do something to the socket
out.println("Hello.");
out.flush();
//close the socket
socket.close();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
This accepts a socket, prints "Hello" to it, then closes it. It should give you some idea of the basic syntax for accepting a socket and doing something to it. If you want to have a true "chat room," you'll need to pass accepted sockets to threads, and save their threads in some appropriate variation of the Collection class. Excuse me if I misunderstood and you already knew all of this, it's just what I assumed you were asking.
> Exactly what part of the US are you referring to?
Every where I've had an Internet connection. Every single ISP I've had all my life since about 1994, while living in New York and Florida.
> Where I am, every single ISP requires that the user request a public IP
> and all assess an additional fee for that.
And what part of the world are you in?
If the ISP-issued IP was a private IP, no one on the Internet would be able to connect to your computer using an arbitrary port. If you can use protocols like bittorrent you have a public IP.
Although it is possible an ISP would use private IP addresses for customers and a NAT and you would be
able to connect to the Internet, no one would be
able to connect to you unless specific ports are mapped to your private IP. If your computer accepts connections
from the Internet on arbitrary ports, you have a public IP.
I am assuming the definitions for public and private IP addresses as defined below. I also assume the OP's home computer is a single computer connected directly to the Internet and not using connection sharing. This last assumption may be wrong since the OP has not defined the home computer environment. I still stand by the statement that ISP's issue public addresses to home accounts. A home user may decide to share this public address with other computers in his home local network which then use private IP addresses. But the ISP-issued address is still a public address.
http://www.talkswitch.com/products/faqs/faq_315.html
-o-
> ok, so for the home network:
>
> how do i use java to open up a connection? like, how
> do i make it accept connections? so far i can only
> accept using the private ip, how can i make it do non
> private ips?
You have not defined your local network. What exactly do you have at home? A single computer or multiple computers? Do you have a router and a modem or just a modem? What type of Internet connection, broadband or dial up?
> > Exactly what part of the US are you referring to?
>
> Every where I've had an Internet connection. Every
> single ISP I've had all my life since about 1994,
> while living in New York and Florida.
>
> > Where I am, every single ISP requires that the user
> request a public IP
> > and all assess an additional fee for that.
>
> And what part of the world are you in?
Central US. I just confirmed with someone else who has lived in different parts of the US and their understanding agrees with mine.
Via research however I suspect that what you and I have seen is in fact different policies for different regions. It appears at least possible that verizon in NY does allocate public (dynamic) IPs to home users as a standard policy.
I wasn't aware that still occurred in major metropolitan areas in the US.
Conversely you should be aware that policy does not apply in other parts of the US.
As to whether one policy or the other is more prevalent (largest number of users) your experience probably trumps mine because the areas you have seen it in have more population.
>
> If the ISP-issued IP was a private IP, no one on the
> Internet would be able to connect to your computer
> using an arbitrary port. If you can use protocols
> like bittorrent you have a public IP.
>
> Although it is possible an ISP would use private IP
> addresses for customers and a NAT and you would be
> able to connect to the Internet, no one would be
> able to connect to you unless specific ports are
> mapped to your private IP. If your computer accepts
> connections
> from the Internet on arbitrary ports, you have a
> public IP.
>
I understand how it works.
You need to understand that the policy you have seen where you live is not universal. (Just as I need to understand that apparently it does occur in some parts of the US.)
> I am assuming the definitions for public and private
> IP addresses as defined below. I also assume the OP's
> home computer is a single computer connected directly
> to the Internet and not using connection sharing.
And you are assuming that their ISP actually is allocating them a public IP (static or not.)
> This last assumption may be wrong since the OP has
> not defined the home computer environment. I still
> stand by the statement that ISP's issue public
> addresses to home accounts.
In some places. Most definitely not all.
And the instructions that you are providing will not work unless they have a public IP.
> As to whether one policy or the other is more prevalent (largest number of
> users) your experience probably trumps mine because the areas you have
> seen it in have more population.
Guess we both made the same mistake :-) It should be relatively easy to test if you have a public IP or not. Install Azureus and download some small popular file. Once complete Azureus will turn into a server for the downloaded file. One can check if people are connecting easily. Or just try pinging your IP from some other computer on the Internet.
What's the difference in price in your area between a private and a public IP account? Just curious.
> all computers that are connected to the home network can connect to the
> internet. each computer is assigned its own private IP. i live in tx using cable
> net.
As we have determined that not all ISPs issue public IP addresses you need to determine if your ISP issued you a public or a private IP. If it is a private IP, you cannot accept connections from the Internet at your home computers. If you have a public IP you should be able to configure your router with an appropriate port mapping. In this case, configuring your router has already been described in previous posts.
hi,
Astrof dont confused yourself. Every computer connected to the internet requires a public IP. in order for local networks to connet to the internet they will need an internet gateway, this gateway usually have the public IP. for some setup like DSL, the DSL router have a public IP.
Your program works in your local network since each computer can see each other's IP address. now, if a computer from the outside of your network needs to connect to one computer inside your network your gateway needs to forward this request from outside the gateway (internet, wan) to the computer inside (local network).
it works more like
192.x.x.x (local IP)--> 203.x..x.x(gateway public IP) -internet>203.x.x.x(gateway public IP)->192.x.x.x(local IP)
you dont actually see the local IP address of computers from another network(behind gateway or firewall) so you cant connect directly to them instead you connect to the gateway and the gateway connects you to the local computer.
you see how complicated it is for a point to point chat program to work over the internet. one solution you can do is to have a single chat server with public IP that will handle and forward request to chat clients. every chat clients only need to establish connetion to this server and once they are connected the server will inter-exchange information to them. that way you will not need public IP address for each chat clients.
i hope this helps...