Jump to content

TCP only works with @IPAddress1


Kip
 Share

Recommended Posts

The title says the most: when i create a client that connects to @IPAddress1 it works fine,

But when I enter my ip address, so the client can connect to the server from others computers, it does nothing.

Weird? Or am i making a mistake somewhere?

Thnx, Kip

Edit: firewall is set to Ok, and the port is opened/forwarded. Tried 127.0.0.1 and 192.168.1.101, but still doesnt work

Edited by kip
Link to comment
Share on other sites

That makes all the difference. I'll try to explain it.

When you connect to a PC over the internet, you use the internet IP.

When you connect to a PC in your network, you use the internal IP.

When you connect to your own PC, you use the internal IP or localhost (127.0.0.1).

If you use ANY other than those IP's it will not work. Trying to connect from your own PC to your own PC using the internet IP, simply won't work. The internet simply wasn't built to do that.

Link to comment
Share on other sites

ok, that makes sense. But how does the client know to which ip he has to connect to?

EDIT: got it:

#include <Inet.au3>

TCPStartup()



$Server_PublicIP = "**.**.***.***"
$Server_LocalIP = "192.168.1.101"

$PublicIP = _GetIP()

$ConnectTo_IP = $Server_PublicIP

If $PublicIP = $Server_PublicIP Then; You're in the same network
    
    $ConnectTo_IP = $Server_LocalIP
    
EndIf


; Connect to $ConnectTo_IP

MsgBox(0,"IP",$ConnectTo_IP)

TCPShutdown()
Edited by kip
Link to comment
Share on other sites

The client (Ludocus) is connecting to me(server) over the internet.

Server listening on @IPAddress1, and client is connecting to my router's ip (the one that _GetIP() on my pc returns)

Or Ludocus is doing something wrong (wouldnt be the first time :D )

Edited by kip
Link to comment
Share on other sites

Its working on my sisters pc (in the network)! :D

You can try if its working by downloading these two files, and running Client.au3. I'll leave the server on for a view hours.

(all that you'll be seeing is a list of processes at my pc)

_TCP.au3

Edited by kip
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...