Jump to content

Can't connect to local server.


 Share

Recommended Posts

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?

Link to comment
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

Link to comment
Share on other sites

  • Moderators

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. :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...