OneManPen Posted December 30, 2011 Share Posted December 30, 2011 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 More sharing options...
jvanegmond Posted December 30, 2011 Share Posted December 30, 2011 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 github.com/jvanegmond Link to comment Share on other sites More sharing options...
OneManPen Posted December 30, 2011 Author Share Posted December 30, 2011 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... Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 30, 2011 Moderators Share Posted December 30, 2011 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 More sharing options...
OneManPen Posted December 30, 2011 Author Share Posted December 30, 2011 ;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 More sharing options...
jvanegmond Posted December 30, 2011 Share Posted December 30, 2011 (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 December 30, 2011 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
OneManPen Posted December 30, 2011 Author Share Posted December 30, 2011 ... 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? Link to comment Share on other sites More sharing options...
jvanegmond Posted December 30, 2011 Share Posted December 30, 2011 (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 December 30, 2011 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
willichan Posted December 30, 2011 Share Posted December 30, 2011 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. jvanegmond 1 My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now