Jump to content

TCP over Internet


Recommended Posts

Ok so I know this question has probably been asked before. but I cant seem to find an answer to fix my problem. I have a simple server running where i was hoping to be able to remotely send commands. but unfortunately I cannot get it to work.

now after reading the forums I said first check that the script runs locally

Check my script works perfectly over my local network

step two set up port forwarding 

ok so I have set up vnc before so I know how to do that

from my work computer type in the public ip address of the computer 

but its still not connecting is there something im doing wrong my script looks like this.

 

thanks in advanced!

Server

TCPStartup()
$never = "1"
$TCPListen = TCPListen(@IPAddress1, 5600)
Do
Do
$TCPAccept = TCPAccept($TCPListen)
Until $TCPAccept <> -1

Do
$TCPRecv = TCPRecv($TCPAccept, 1000000)
Until $TCPRecv <> ""

If $TCPRecv = "Eject CDTray" Then
  CDTray("D:", "open") 
  EndIf
  
  If $TCPRecv = "Close CDTray" Then
  CDTray("D:", "closed") 
  EndIf
  
  If $TCPRecv = "Launch XBMC" Then
 ProcessClose("XBMC.exe")
  Run("C:\Program Files\XBMC\XBMC.exe")
  EndIf
  
    If $TCPRecv = "Launch Chrome" Then
 ProcessClose("Chrome.exe")
ShellExecute("www.google.com")
  EndIf
  
  If StringLeft($TCPRecv, 4) = "msg " Then
     $Message = StringTrimLeft($TCPRecv, 4)
     MsgBox(0, "Client Says", $Message)
  EndIf
  
   If StringLeft($TCPRecv, 8) = "torrent " Then
         $Torrent = StringTrimLeft($TCPRecv, 8)
         ShellExecute($Torrent)
      EndIf
        If StringLeft($TCPRecv, 4) = "run " Then
     $Run = StringTrimLeft($TCPRecv, 4)
    Run($Run)
  EndIf
         If StringLeft($TCPRecv, 8) = "Execute " Then
         $Command = StringTrimLeft($TCPRecv, 8)
         ShellExecute($Command)
      EndIf
             If StringLeft($TCPRecv, 8) = "Process " Then
         $Command = StringTrimLeft($TCPRecv, 8)
        ProcessClose($Command)
      EndIf
until $never = "2"

Client

#include <GUIConstantsEx.au3>

TCPStartup()

$SeverIP = InputBox("Andre's Client", "What is the IP address")


Example()

Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("Andre's Client") ; will create a dialog box that when displayed is centered


    $Button_1 = GUICtrlCreateButton("Message", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("Open Chrome", 110, 30, 100)
$Button_3 = GUICtrlCreateButton("Open XBMC", 210, 30, 100)
$Button_4 = GUICtrlCreateButton("Open Tray", 10, 60, 100)
$Button_5 = GUICtrlCreateButton("Close Tray", 110, 60, 100)
$Button_6 = GUICtrlCreateButton("Add Torrent", 210, 60, 100)
$Button_7 = GUICtrlCreateButton("Execute", 10, 90, 100)
$Button_8 = GUICtrlCreateButton("Run", 110, 90, 100)
$Button_9 = GUICtrlCreateButton("Close Process", 210, 90, 100)
    GUISetState() ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
             Case $msg = $Button_1
                $message = InputBox("Client", "what would you like to say?")
                $Messagecmd = "msg " &  $message            
                $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                TCPSend($TCPConnect, $Messagecmd)
            Case $msg = $Button_2
              $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                    TCPSend($TCPConnect, "Launch Chrome")
                     Case $msg = $Button_3
              $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                    TCPSend($TCPConnect, "Launch XBMC")
               Case $msg = $Button_6
                $Torrent = InputBox("Client", "Paste Magnetic Link Here")
                $torrentcmd = "torrent " &  $Torrent        
                $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                TCPSend($TCPConnect, $torrentcmd)
                                     Case $msg = $Button_4
              $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                    TCPSend($TCPConnect, "Eject CDTray")
               Case $msg = $Button_5
              $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                    TCPSend($TCPConnect, "Close CDTray")
                  Case $msg = $Button_7
                $Execute = InputBox("Client", "type execute cmd")
                $executecmd = "Execute " &  $Execute        
                $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                TCPSend($TCPConnect, $executecmd)
                                  Case $msg = $Button_8
                $run = InputBox("Client", "type run cmd")
                $runcmd = "Run " &  $run        
                $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                TCPSend($TCPConnect, $runcmd)
               Case $msg = $Button_9
                $Process = InputBox("Client", "what to close")
                $Processcmd = "Process " &  $Process        
                $TCPConnect = TCPConnect($SeverIP, 5600)
                if $TCPConnect = -1 then Exit
                TCPSend($TCPConnect, $Processcmd)
        EndSelect
    WEnd
EndFunc   ;==>Example
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...