Sign in to follow this  
Followers 0
OneManPen

Can't connect to local server.

9 posts in this topic

I'm writing a chat program and I making using basic TCP... Most of the code is from the help file... So the point is... I'm trying to add a feature where the user can connect to any server... As long as it's online of course. And while working on commands I found a bug or something where I can only connect to local server using @IPAddress1, if I try using 127.0.0.1 or my local ip which is what it aways seems to be if I echo it..... So I'm wondering if this is just a local host bug... or does it have the same effect on other comps?

Share this post


Link to post
Share on other sites



I'm writing a chat program and I making using basic TCP... Most of the code is from the help file... So the point is... I'm trying to add a feature where the user can connect to any server... As long as it's online of course. And while working on commands I found a bug or something where I can only connect to local server using @IPAddress1, if I try using 127.0.0.1 or my local ip which is what it aways seems to be if I echo it..... So I'm wondering if this is just a local host bug... or does it have the same effect on other comps?

And how would you connect to another computer in another way than their ip address? You can only use a loopback[1] address if you want to reach your own computer.

Do you understand? I can try to explain more. Perhaps you'd also like to know why it's not a "local host bug"?

[1] 127.0.0.1 is the IP address which indicates that messages should be looped back to your own computer

Share this post


Link to post
Share on other sites

Lol... I realize that... But 127.0.0.1 isn't working..., how ever @IPAddress says it's connecting using 192.168.0.2, which is my local IP... Which shouldn't work and doesn't work...

Share this post


Link to post
Share on other sites

Hi, SleeperCell42. @IPAddress1 should resolve to your local IP (127.0.0.1 on some computers, according to the Help file). Are you expecting it to resolve to something else? If we are not understanding your intent, perhaps posting some of the troublesome code will help us help you. :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

;This one would work...
TCPStartUp()
$TCP_Connect = TCPConnect( @IPAddress1, 65432 )
If $TCP_Connect = -1 Then Exit
;This one would not
TCPStartup()
$Input_ip = InputBox("Input the IP you wish to connect to", "")
$TCP_Connect = TCPConnect( $Input_ip, 65432)

This is what the problem is... If I manually input the IP... It would not connect... but if I use @IPaddress1 it would.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

JLogan, @IpAddress1 translates to an address like 192.168.0.100. However, this is not guaranteed and it could be 127.0.0.1. Depends completely on your local setup.

Lol... I realize that... But 127.0.0.1 isn't working..., how ever @IPAddress says it's connecting using 192.168.0.2, which is my local IP... Which shouldn't work and doesn't work...

The reason it doesn't work is because of the TCPListen on the other end. It only listens on a single IP address: It's either 127.0.0.1 or @IpAddress1 (or 2, 3, 4, or anything else for that matter).

Edit:

This is what the problem is... If I manually input the IP... It would not connect... but if I use @IPaddress1 it would.

@IpAddress1 is not always "127.0.0.1". Most of the time it isn't. It's more often the 192.168.*.* address. If you try to put this in manually, it will work just the same.

Test with:

MsgBox(0, "", @IpAddress1)
Edited by Manadar

Share this post


Link to post
Share on other sites

... Ah... I understand now... But quick question... so I can't have people connecting to my external ip if I have it listening on 127.0.0.1?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

That's correct.

Edit: You can use multiple TCPListen, but you then also have to use multiple TCPAccept. I've never tried, but I think if you create an array of connections, you can mix connections coming from multiple IPs easily anyway.

Edited by Manadar

Share this post


Link to post
Share on other sites

so I can't have people connecting to my external ip if I have it listening on 127.0.0.1?

To avoid the headache from the next barrier you are likely to hit, you might also want to make sure you understand Network Address Translation and Port Forwarding.

1 person likes this

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  
Followers 0