Jump to content

TCP over Internet


Recommended Posts

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

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

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

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

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

Link to comment
Share on other sites

  • 1 month later...

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!

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