Jump to content
Sign in to follow this  
Alexxander

problem in TCP functions

Recommended Posts

Alexxander

hi all 

 i had made 2 scripts the first one send a shutdown command to a second script in a another PC  in another network (SENDER)

the other script receives the order and shut down (RECIVER)

SENDER's code

#include <GUIConstantsEx.au3>
GUICreate("", 300,300)
$com = GUICtrlCreateCombo("", 100, 75, 70, 100, 0x0003)
GUICtrlSetData($com, "Shutdown|Reboot|Logoff|Standby|Hibernate")
$but = GUICtrlCreateButton("Send command", 85, 150, 100,50)
GUISetState()
TCPStartup()

While 1
    $nMsg = GUIGetMsg()
    if $nMsg = $GUI_EVENT_CLOSE Then Exit
    if $nMsg = $but Then check()
WEnd

Func check()
    $check = 0
    If  GUICtrlRead($com) = "" Then $check = 1
    if $check = 1 then MsgBox (0, "","Fill it")
    if $check = 0 Then but()
EndFunc


func but()
    $TCPConnect = TCPConnect("82.137.235.81", 555)
    TCPSend ($TCPConnect, GUICtrlRead($com))

EndFunc

reciver's code

TCPStartup()

$TCPListen = TCPListen(@IPAddress1, 555)
Do
$TCPAccept = TCPAccept ($TCPListen)
Until $TCPAccept <> -1
Do
$TCPRecive = TCPRecv ($TCPAccept, 1000000)
Until $TCPRecive <> ""


    $var = 0
    if $TCPRecive = "Shutdown" Then $var = 1
    if $TCPRecive = "Reboot" Then $var = 2
    if $TCPRecive = "Logoff" Then $var = 0
    if $TCPRecive = "Standby" Then $var = 32
    if $TCPRecive = "Hibernate" Then $var = 64
    if $TCPRecive = 1 Then $var = $var + 4
    if $TCPRecive = 4 Then $var = $var

MsgBox(0,"",$var)
;Shutdown($var)

it was working fine when i used @ipadresses in both scripts on the same pc

but when i repalced @ipadresses1 with the public IP (every script on a pc and separate networks)it wont work 

any ideas what i'm missing ?

thanks in advanced

Edited by alexander95

Share this post


Link to post
Share on other sites
trancexx

Public IP means nothing to your receiver script until you you do what's called port forwarding. That's basically translating the adress (and/or ports) from one to another done by your router. Google a bit.

After that you would probably need to adjust firewall settings to allow traffic on port 555 (your script).


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Alexxander
@trancexx

 

Tnx fro replay bro

is there is any way i can make connection between 2 pcs wothout port frpwarding ?

what will happen if i made it port 80 which is opened be default ?

correct me if i'm wrong


Share this post


Link to post
Share on other sites
trancexx

No problem bro.

You are wrong, port 80 is not "opened" by default. You can check your ports for example here.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Alexxander
trancexx

 

so there is no way to establish a P2P connection without PF ?


Share this post


Link to post
Share on other sites
trancexx

That depends on the several things but I would say that in 99.99% cases that's true. You need port forwarding.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Alexxander
trancexx

 

can u tell me the several things ?

and what is the 0,01 % ?

PS: i know i'm too annoying


Share this post


Link to post
Share on other sites
trancexx

trancexx

 

 

can u tell me the several things ?

and what is the 0,01 % ?

That's out of the control of the user.

PS: i know i'm too annoying

Actually the only annoying thing is that you link my name to my profile so when I click thinking it's useful link I end up here.

Oh and "u" for "you" is also annoying and "tnx".

...Ehh now that I think about it, you are right.

  • Like 1

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Alexxander

trancexx

anyway tnx u for helping 

  • Like 1

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  

×