• Post Reply Bookmark Topic Watch Topic
  • New Topic

Port forwarding in C++ vs Java

 
James Varn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
Paul Clapham
Sheriff
Posts: 21876
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I see, thank you for the help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!