Sign in to follow this  
breakspirit

boost::asio - how to remotely connect to my server?

Recommended Posts

I've got a total noob question. I'm learning to use boost::asio and am playing with examples. Well, when I run a server, I can connect just fine using telnet if i connect to localhost and my specified port (telnet localhost 7777).
However, others can not connect via telnet to my server using my outside ip and the same port(which I did remember to forward). I feel like I'm missing something stupid and obvious. My listen command is below:

acceptor->Listen( "127.0.0.1", 25570 );

Thanks for any help.

Edit:
I thought of another question. I don't understand why the listen method needs my IP. My friend says its because you can have multiple IPs. Does that make sense?

Share this post


Link to post
Share on other sites
[quote name='breakspirit' timestamp='1317239186' post='4866918']
I've got a total noob question. I'm learning to use boost::asio and am playing with examples. Well, when I run a server, I can connect just fine using telnet if i connect to localhost and my specified port (telnet localhost 7777).
However, others can not connect via telnet to my server using my outside ip and the same port(which I did remember to forward). I feel like I'm missing something stupid and obvious. My listen command is below:

acceptor->Listen( "127.0.0.1", 25570 );

Thanks for any help.

Edit:
I thought of another question. I don't understand why the listen method needs my IP. My friend says its because you can have multiple IPs. Does that make sense?
[/quote]

See the forum FAQ, the blue link near the top of the page. And yes, your friend is correct, as described in the FAQ.

Read the linked content inside FAQ entries #1, #9, and #18

There are several potential issues involved. I'd say NAT is the most likely, and since you have forwarding on your local router you might be behind two or more levels of NAT through your ISP.

Share this post


Link to post
Share on other sites
Thanks for the reply. I've already read the FAQ and the suggested entries therein. It is mostly fluff. Upon further inspection, it was found that using my internal IP as the server IP would enable others to connect to me correctly. The line of code in question is show below:

acceptor->Listen( "192.168.11.2", 25570 );

Like I said, I knew it would be something stupid and simple.

Share this post


Link to post
Share on other sites
Check this guy's journal out!
[url="http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting-started-with-boostasio/"]http://www.gamedev.n...with-boostasio/[/url]
Helped me out.

Edit: Realized you solved your problem. But still, that entry is a good read for ASIO.

Share this post


Link to post
Share on other sites
[quote name='Imgelling' timestamp='1317242551' post='4866946']
Check this guy's journal out!
[url="http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting-started-with-boostasio/"]http://www.gamedev.n...with-boostasio/[/url]
Helped me out.

Edit: Realized you solved your problem. But still, that entry is a good read for ASIO.
[/quote]

Yeah, that's exactly where I learned everything I know about asio. It was indeed a good read. Thanks for posting it.

Share this post


Link to post
Share on other sites
[quote name='breakspirit' timestamp='1317242365' post='4866944']
Thanks for the reply. I've already read the FAQ and the suggested entries therein. It is mostly fluff. Upon further inspection, it was found that using my internal IP as the server IP would enable others to connect to me correctly. The line of code in question is show below:

acceptor->Listen( "192.168.11.2", 25570 );

Like I said, I knew it would be something stupid and simple.
[/quote]

What you reall want to listen to is "0.0.0.0" which is short-hand for "any available network interface" (INADDR_ANY in code).

Share this post


Link to post
Share on other sites
[quote name='hplus0603' timestamp='1317247462' post='4866969']
[quote name='breakspirit' timestamp='1317242365' post='4866944']
Thanks for the reply. I've already read the FAQ and the suggested entries therein. It is mostly fluff. Upon further inspection, it was found that using my internal IP as the server IP would enable others to connect to me correctly. The line of code in question is show below:

acceptor->Listen( "192.168.11.2", 25570 );

Like I said, I knew it would be something stupid and simple.
[/quote]

What you reall want to listen to is "0.0.0.0" which is short-hand for "any available network interface" (INADDR_ANY in code).
[/quote]

You are a gentleman and a scholar.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this