Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Client connects to Server from within network, not from outside

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I made two Java programs: a server and a client. The server uses ServerSocket, and the client uses Socket. The (made-up) IP address in the String "host" below is my IPv4 address.

I instantiate the Socket as follows:


I was able to connect my client to my server from a separate computer on my own network. I'd made an exception in my firewall for port 2222, and I also dug into my router settings and had it forward to port 2222.

PROBLEM: Now, when I keep my Server program running on computer A and I take computer B to ANOTHER network... I get an IOException (see above code for how this is handled). Am I using the wrong kind of IP address? or is there something else besides port forwarding and firewall exceptions I haven't yet accounted for?

Please let me know if you need any more information to help me solve this problem.

Thanks,
Michael
 
Michael Baucum
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a more full listing of the code involved:
















The Client and Server code is what I'm asking about; the rest is there for you to see what I'm going to be doing with it.



If
 
Marshal
Posts: 25818
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Michael Baucum wrote:PROBLEM: Now, when I keep my Server program running on computer A and I take computer B to ANOTHER network... I get an IOException (see above code for how this is handled). Am I using the wrong kind of IP address? or is there something else besides port forwarding and firewall exceptions I haven't yet accounted for?



Yes. The IP address 192.168.0.6 in that other network may or may not exist, but it certainly isn't computer A. Computer A isn't even in that other network.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic