KenanDeHart Posted November 21, 2012 Share Posted November 21, 2012 I am unable to send a variable over a UDP connection. Please excuse my poor english. (For full story, read spoiler) Hello, I am attempting to create a program that will allow me to do simple things with my friends computer at school. His computer is right next to mine, and since we work on projects together, we continually need to show each other pieces of code, websites, cmd commands, etc.... My plan is to create a UDP connection in which the "server" is on his computer and the "client" is on mine. I am 100% new to autoit, so I have been consistently having basic issues. While I have been able to figure most of them out on my own, I can't solve this one simple problem. I am trying to make an option for me to see all of the running processes on his computer. I am first trying to get the total number of processes running on his computer so I can make an array, I am able to find the total number of processes, but when I try to send that number, I seem to receive some sort of memory address on my side. Look at the code below please Here is where I am having a problem. On the server side: $list = ProcessList() For $i = 1 To $list[0][0] $totalproc = $totalproc + 1 Next $n=1 UDPSend($sendsocket, $totalproc) On the client side: While $Procreq = "" local $Procreq = UDPRecv($recvsocket, 1000000) If $Procreq <> "" Then MsgBox(1,"",$Procreq) EndIf Sleep(100) WEnd The message box displays the following value for $procreq "0x36000000" This kind of looks to me like a memory address, but I am not sure. If you have any questions, or need further explanation, let me know. Link to comment Share on other sites More sharing options...
KenanDeHart Posted November 21, 2012 Author Share Posted November 21, 2012 Here is a full source of both the client and of the server, in case it will be useful. SERVERexpandcollapse popup#include <Process.au3> UDPStartup() $totalproc = 0 ; Register the cleanup function. OnAutoItExitRegister("Cleanup") ; Bind to a SOCKET ;============================================== Global $recvsocket = UDPBind(@IPAddress1, 65532) If @error <> 0 Then Exit Global $sendsocket = UDPOpen(@IPAddress1, 65531) If @error <> 0 Then Exit While 1 $Proccheck = "0" Local $data = UDPRecv($recvsocket, 50, 2) If $data <> "" Then MsgBox(1,"",$data[0]) If $data[0] = "PR" Then MsgBox(1,"","Server received process list request") $list = ProcessList() For $i = 1 To $list[0][0] $totalproc = $totalproc + 1 Next $n=1 UDPSend($sendsocket, $totalproc) $data = "" $Proccheck = "1" EndIf If $Proccheck = "0" Then _RunDos($data[0]) EndIf EndIf Sleep(100) WEnd Func Cleanup() UDPCloseSocket($recvsocket) UDPCloseSocket($sendsocket) UDPShutdown() EndFunc ;==>Cleanup CLIENT expandcollapse popup#include <Process.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Local $Procreq = "" UDPStartup() Global $sendsocket = UDPOpen(@IPAddress1, 65532) If @error <> 0 Then Exit Global $recvsocket = UDPBind(@IPAddress1, 65531) If @error <> 0 Then Exit $ClientGUI = GUICreate("Control Panel", 615, 306, 192, 124) ;notepad section $notepad = GUICtrlCreateButton("Start notepad", 24, 16, 129, 41) $notepadstream = GUICtrlCreateButton("Begin text streaming", 160, 16, 129, 41) $notepadinput = GUICtrlCreateInput("", 296, 24, 313, 21) ;Opening a URL $url = GUICtrlCreateButton("Open this URL ->", 24, 80, 131, 41) $urlinput = GUICtrlCreateInput("", 160, 88, 201, 21) ;View / Kill processes $procmang = GUICtrlCreateButton("Open process manager", 24, 144, 131, 41) ;Run a CMD command $customcmd = GUICtrlCreateButton("Run a CMD command", 24, 208, 129, 41) $cmdinput = GUICtrlCreateInput("", 160, 216, 201, 21) ;For a later use $Button2 = GUICtrlCreateButton("Empty", 438, 80, 131, 41) $Button3 = GUICtrlCreateButton("Empty", 440, 150, 131, 41) $Button4 = GUICtrlCreateButton("Empty", 437, 212, 129, 41) GUISetState(@SW_SHOW) While 1 $Proclist = "" $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $notepad Local $status = UDPSend($sendsocket, "start notepad") If $status = 0 Then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf Case $url Local $status = UDPSend($sendsocket, "start " & GUICtrlRead($urlinput)) If $status = 0 Then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf Case $customcmd Local $status = UDPSend($sendsocket, GUICtrlRead($cmdinput)) If $status = 0 Then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf Case $procmang Local $status = UDPSend($sendsocket, "PR") If $status = 0 Then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf While $Procreq = "" local $Procreq = UDPRecv($recvsocket, 1000000) If $Procreq <> "" Then MsgBox(1,"",$Procreq) EndIf Sleep(100) WEnd EndSwitch WEnd Func Cleanup() UDPCloseSocket($recvsocket) UDPCloseSocket($sendsocket) UDPShutdown() EndFunc ;==>Cleanup Link to comment Share on other sites More sharing options...
KenanDeHart Posted November 21, 2012 Author Share Posted November 21, 2012 Sorry guys, just realized that is hexadecimal. Lol. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now