Sign in to follow this  
Followers 0
KHn

TCP over Internet

14 posts in this topic

Hello there, i've been looking for a way to connect two programs: a client and a server with TCP over the internet, but i hadn't succeded

I've been also looking all over the forum, but i coulnd't find anything that works

What i am doing is simple:

Serverside:

TCPListen(@IPadress1,$port)

Clientside:

TCPConnect($PublicIPAdress,$port)

Where $port could be something like 12346

That's just a part of the code, the IP, and port values are the ones which i think are the problem, but they are just like the normal ones, i still dopn't understand why this doesn't work

I've tested lots of different scripts found on the forum with differents friends all over the world, but there's no case

I would apreciate a lot if you could help me

Thanks in advance

Share this post


Link to post
Share on other sites



If you are doing this on the same network you shouldnt use the PUBLIC IP address which has your router, but the internal IPaddress which has the server like 192.168.1.1 or something... Reversed NAT is a bitch.

Share this post


Link to post
Share on other sites

No i'm not trying to connect them on the same network, but on different networks, separated by routers, as i said, all over the world, that's why i use the public IP address

And i guess that's the problem, This AutoIT TCP funciont doesn't work on any other side than in the same network

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Most personal routers require NAT traversal, so you can have multiple devices appearing to be one IP (your ISP only assigns you one IP). Because of this, you have to "open" ports on your router into order to establish communication. That's most likely the problem here. On the computer that you want to connect *to*, you should find the router model and look up via Google how to do "port forwarding" or open up ports on that specific router. The client does not need to open up ports but the server most definitely will.

Alternatively, I'm waiting for someone to come up with a UDP hole punching UDF, that'd fix all the problems of NAT traversal.

Edited by Yorn

Share this post


Link to post
Share on other sites

I'm not experienced with this, but to my understanding the public IP is the IP the router gets from your ISP to connect to the internet. As there could me multiple computers on your home network, the router has no way to determine what PC the TCP connection was meant for.

You probably have to configure the router to foreward all TCP connections on your specified port to the correct PC. Perhaps write a script that can configure upnp routers.

If you have multiple pc's on a network running the program I think you'll need to set them to use unique ports and make a rule in your router for each port/PC used.

Someone will have to confirm this though. Never realy looked into the subject.

Share this post


Link to post
Share on other sites

Then you have to forward your port to the server properly. It does work over the internet, only if you configged your routers the right way.

Ive made alot of tools work with TCPsend :idea:

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

But when i run the command window (CMD) i write netstat -a -b, and i fin the port listening while i'm running the server.

The port which appears in the CMD is the same i am running with the TCP program, so i thought it sould work fine

I'll re-look again in that Port forwarding theme, but the thing is that i am behind an wireless switch and behind the router

EDIT: i do not understand womething: Why with autoit you have to forward ur ports while in most applications you dont have to do that? (manually)

Edited by KHn

Share this post


Link to post
Share on other sites

bump :idea:

Share this post


Link to post
Share on other sites

Well, here is something to try. On the Server side, change the IP Address you listen to from @IPaddress1 to "0.0.0.0". That will tell your program to accept incoming connections on any port, internal or external.

As for Port Forwarding, that would depend on your setup. If your computer is connected directly to the internet, then you won't need it. If you have a router, it would need to know to forward traffic from the port to your PC/IP, otherwise it wouldn't know whether to give you the data, or send it to another computer, or deal with it itself.

Share this post


Link to post
Share on other sites

I GOT IT!!!!!

I tell you what i did:

Port Forwarding: the port i was using (in this case 12345)

the ip to the port i forward is the same as @ipAdress1

in the TCPConnect() i use the public IP of the host

OH i'm so happy right now!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ahahaha tyvm!!

Share this post


Link to post
Share on other sites

Yes, its always needed to forward ports if you want to reach something behind a router. Forward port from outsideIP > inside IP.

Share this post


Link to post
Share on other sites

The ports are like doors, numbered 1-65535. When a port is forwarded, it is like unlocking that door so that traffic can go through it. The same goes for your computer, if your server is listening on port 12346, that 'door' is unlocked, so that traffic can come in. That analogy sometimes helps...

Share this post


Link to post
Share on other sites

The ports are like doors, numbered 1-65535. When a port is forwarded, it is like unlocking that door so that traffic can go through it. The same goes for your computer, if your server is listening on port 12346, that 'door' is unlocked, so that traffic can come in. That analogy sometimes helps...

not here...

think of port forwarding as a mail service(envelopes and stamps... old school)

no port forward means:

you send a letter to someone's PO box(person X), the letter arrives in the destination postal office but the postman dosen't know who the box belongs to so person X dosen't know he has mail.

port forwarding:

if a letter comes to the post office to person X's PO box then the mailman forwards it to person X's home...

or something like that :-"


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

Hello every body  . hey   KHn : would u please tell us what is the good script now that works with TCP receive and send between 2 pcs on the internet?

please can u visit my question here: http://www.autoitscript.com/forum/index.php?showtopic=116386

please help!

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