• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Port forwarding in C++ vs Java

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am a student who is writing two simple programs (one which sends some data from the user client to the other program, and one which takes that data and outputs it on the screen) for a class assignment. We were told to write the code in C or C++ using the socket.h and in.h files, but I got permission from the professor to write the program in Java instead, since I'm more familiar with the language and have used the Socket/ServerSocket classes for a previous class, as long as I get everything to work. It also served as a bit of a review for me, since I haven't tried networking in Java for a year or two. However, after writing my code, I recalled that, in order to connect a Socket to a ServerSocket across the internet, given the ServerSocket's IP address and port, we were told, in the previous class, to port forward from the server computer by fiddling around with the computer's router from outside the program; otherwise, the client could not connect to the server. I was able to get my code to work when connecting to localhost, but not to another computer across the internet running the server program. My current class's assignment made no references towards needing to port forward, and all of the material we were given seem to indicate that the only thing we needed to do to get the program to connect was to call the C socket functions. Is what I remember about having to port forward in order to connect in Java accurate? If so, does this restriction hold for C/C++ sockets as well?
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, what you said about connecting across the Internet sometimes requiring configuration of the LAN containing the server is correct. This is a networking issue and has nothing to do with the programming language used to write the networking code.

As for why your current instructions don't mention that, all I can suggest is that you said they were "simple" programs. In other words they are designed to teach simple network programming; talking about port forwarding would just confuse and distract.
 
James Varn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see, thank you for the help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic