Jump to content
  • Advertisement
Sign in to follow this  
Aqua Costa

[C++] Socket servers

This topic is 2562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to do something like this:
-When server is turned on it stores its IP in an online DB.
-The client reads the IP stored in the DB and connects to the server using the IP.

The problem is that I never managed to connect a client and a server using sockets without using "localhost" has IP address.
-How can I get the server IP address using C++?
-Do I have to open the ports I want to use in my socket? How do I open them?
-Can I use "default" open ports?

Share this post


Link to post
Share on other sites
Advertisement

How can I get the server IP address using C++?
[/quote]
You generally don't want to do this. First, you may have multiple interfaces, with different IP addresses. Also, the server could be behind a NAT. Instead, the online database should discover the remote peer's address when it accepts a connection.


Do I have to open the ports I want to use in my socket? How do I open them?
[/quote]
If you are behinda firewall or NAT, yes. How to do so varies with the firewall/NAT.


Can I use "default" open ports?
[/quote]
There are a handful of ports that are almost certainly open for outgoing connections, like HTTP and HTTPS for example. The default on many networks is to have no open ports for incoming connections.

Share this post


Link to post
Share on other sites
Hi, im also having problem with my app because of routers behind nats, i've read the article above and understand most of it, but it says at the end that the introducer/server ..."can be run without paying huge bandwidth bills for servers". This leave me with the question, if the "introducer server" cant be run by both clients behind routers, what do you use to build such a system? A Web page using PHP? I've read somewhere else that most web pages hoster wont let code run indefinitely.

Sorry if my question is not clear but it would be nice to have example of how to implement such a system.

Share this post


Link to post
Share on other sites

Hi, im also having problem with my app because of routers behind nats, i've read the article above and understand most of it, but it says at the end that the introducer/server ..."can be run without paying huge bandwidth bills for servers". This leave me with the question, if the "introducer server" cant be run by both clients behind routers, what do you use to build such a system? A Web page using PHP? I've read somewhere else that most web pages hoster wont let code run indefinitely.

Sorry if my question is not clear but it would be nice to have example of how to implement such a system.


Hey,

check these articles:
-http://lifehacker.com/software/feature/special-how-to-access-a-home-server-behind-a-routerfirewall-127276.php
-http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server

I haven't tried it yet though...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!