Hello. Yesterday and today I've learned a few basic things about making sockets in Java an using them to create client/server-type applications. The problem here is that I'm not seeing much in the way of really simple, beginner's tutorials about how to apply that across more than a single computer (specifically across the Internet). All I've seen so far at least looks like it would only work on a single computer (they use localhost as the server, don't get into URLs, etc.). Does anybody have a good link to such a tutorial please? Thanks!
The reason you aren't seeing those specialized tutorials is that there isn't any difference between a socket connecting your application to a server on localhost and a socket connecting your browser to www.coderanch.com. You don't have to write your code any differently either.
Do you have a specific problem behind this question, or are you just asking out of curiosity?
Well, I haven't actually tried doing this across multiple computers, but it's just hard for me to see how it would know which thing to connect to if I didn't pass it some sort of information that describes where the server is and what it is. Below I've included the actual code I was using for the client side. What would I have to change if I were to try to access the server across the Internet, instead of on the same computer?
Now what I'm having trouble with is the following: I'm using a wireless router, and when I call InetAddress.getByName(<some sort of internal, local ip>) on my own computer, that works just fine. But then when I try to call InetAddress.getByName(<the router's ip>), either on my own computer or on another one on the same router, that doesn't work. What's the problem?
you are getting this exception because the socket server is not running at the specified port of the specified host. When you get 'Connection refused', it is either your socket server doesn't run or firewall/security rights issue.