Re: TCP/IP file transfer and a router
aca04pds@shef.ac.uk wrote:
Hi
I'm trying to create a Java program that can send a file from 1
Windows PC to another over a TCP/IP connection. As many people use
[wireless] routers, how can I create a TCP connection to PCs that are
connected to the internet via a router? The router has an IP and then
each PC connected to that has its own IP for their local network. How
would the router know which PC is the right one to send the data to?
All help is appreciated, thanks.
What Steven said. But rather than IP addresses, you should assign names
to the PCs, and use those instead. Usually, this is called the "host
name" and it's the same name that you'd use connecting to load a web
page or similar. If you're creating a connection based on a user
loading a file to a web server, for example, you should use the URL they
already have and extract the host name from that. For
www.cnn.com/upload, for example, the host name would be www.cnn.com or
cnn.com (because www might not know how to upload random files).
If your Java app is 100% stand alone, allow the user to type in the host
name themselves, just like you can with a gui FTP program.
Speaking of gui FTP programs, why not just use one of those? All the
hard work is done for you....