2words4uready Posted August 8, 2008 Share Posted August 8, 2008 My attempt at a client/server program. Can someone help. It doesn't work. Client expandcollapse popup#include <GUIConstants.au3> #include <INet.au3> #include <TCP Funcs.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Tyler\Desktop\client.kxf $Form1 = GUICreate("Form1", 306, 197, 193, 125) $ip = GUICtrlCreateInput("0.0.0.0", 64, 8, 225, 21) GUICtrlCreateLabel("Target IP", 8, 8, 48, 17) $Message = GUICtrlCreateEdit("", 0, 40, 305, 73) GUICtrlSetData(-1, "Message") $exe = GUICtrlCreateInput("Exe To Run", 0, 136, 305, 21) $send = GUICtrlCreateButton("Send Message", 0, 168, 81, 17, 0) $runexe = GUICtrlCreateButton("Run EXE", 208, 168, 81, 17, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $go = GUIGetMsg() While 1 Select Case $go = $send ; ButtonPress $mess = GUICtrlRead($message) $target = GUICtrlRead($ip) TCPStartup() $Socket=TCPConnect($target,7000) TCPSendMessage($Socket,$mess) ;send the message TCPCloseSocket($Socket) ;close the connection TCPShutdown() Case $go = $runexe ; ButtonPress $mess = GUICtrlRead($exe) $exe2 = GUICtrlRead($exe) TCPStartup() $Socket=TCPConnect($target,7000) TCPSendMessage($Socket,$exe2) ;send the message TCPCloseSocket($Socket) ;close the connection TCPShutdown() EndSelect WEndoÝ÷ Ù'«½êÚºÚ"µÍÚ[ÛYH ÓZØË]LÉÝÂÚ[ÛYH ÕÔ[ÜË]LÉÝÂÚ[ÛYH Û^HÛY[]LÉÝÂÚ[ÛÜÙJ ][ÝÑÜHI][ÝÊBØØ[ ÌÍÐÛÛXÝYÛØÚÙ]HLBÌÍÓXZ[ÛØÚÙ]HÔÝÙ Ì HÛÜ[HÜ ÌÚ[HBÌÍÐÛÛXÝYÛØÚÙ]HÔXØÙ ÌÍÓXZ[ÛØÚÙ] HØXØÙ[[ÈÛÛXÝ[ÛY ÌÍÐÛÛXÝYÛØÚÙ] ÝÈ[ÌÍÑ]HHÔXÙZ]J ÌÍÐÛÛXÝYÛØÚÙ] HÝZÙHHYÜØYÙBY ÌÍÐÛÛXÝYÛØÚÙ] ÉÝËLH[TÙ[XÝPØÙH[ ÌÍÙ^LBQ[Ù[XÝ[Y[YÑ[ Link to comment Share on other sites More sharing options...
Nahuel Posted August 8, 2008 Share Posted August 8, 2008 I'll post the one I created so you can get some ideas from it. It's very simple. SERVER expandcollapse popup;Server Script. RUN FIRST TCPStartUp() $MainSocket = TCPListen(TCPNameToIP(@computername), 65432, 100 ) If $MainSocket = -1 Then Exit While 1 $ConnectedSocket = TCPAccept( $MainSocket) If $ConnectedSocket >= 0 Then msgbox(0,"","connected",1) ExitLoop EndIf Wend While 1 $Message=TCPRecv($ConnectedSocket,2048) Sleep(25) If $Message<>"" Then Switch $Message Case "IPAddress" $Info=@IPAddress1 Case "ComputerName" $Info=@ComputerName Case "UserName" $Info=@UserName Case "LogonDomain" $Info=@LogonDomain Case Else $Info="Unknown command" EndSwitch TCPSend($ConnectedSocket,$Info) EndIf WEndoÝ÷ Ø"ÈÔÚºÚ"µÍÚ[ÛYH ÑÕRPÛÛÝ[Ë]LÉÝÂÕRPÜX]J ][ÝÑÜLI][ÝËÌLËKÌMLBÌÍÐÛÛ[X[HÕRPÝÜX]R[] ][ÝÉ][ÝË MKKJBÕRPÝÜX]SX[ ][ÝÑ[HXXÜÈ[ÝHØ[ÈÙ]Ú]Ý]H ][ÝËÍMKMÊBÌÍÔÙ[HÕRPÝÜX]P]Û ][ÝÉ[ÔÙ[ ][ÝËL L K K ÌÍÐ×ÑQTÒUÓBÕRTÙ]Ý]JÕ×ÔÒÕÊBÔÝ BÌÍÔÙI][ÝÌLI][ÝÎÑ[[Ý[[ÝHÛÛ ÌÎNÜÈTBÌÍÓXZ[ÛØÚÙ]UÔÛÛXÝ ÌÍÔÙ MÌBY ÌÍÓXZ[ÛØÚÙ]HLH[SÙÐÞ ][ÝÉ][ÝË ][ÝÐÛÝ[ÝÛÛXÝÈÙ][ÝÊBQ^][YÙØÞ ][ÝÉ][ÝË ][ÝØÛÛXÝY ][ÝËJBÚ[HBIÌÍÛÙÈHÕRQÙ]ÙÊ BTÝÚ]Ú ÌÍÛÙÂBPØÙH ÌÍÑÕRWÑUSÐÓÔÑBBBQ^]BPØÙH ÌÍÔÙ[BBTÙ[]YÝ BQ[ÝÚ]ÚTÝ]J BÑ[[ÈÙ[]YÝ BIÌÍÜÔOQÕRPÝXY ÌÍÐÛÛ[X[ BUÔÙ[ ÌÍÓXZ[ÛØÚÙ] ÌÍÜÔJB[[Â[ÈÝ]J BIÌÍÑ]OUÔXÝ ÌÍÓXZ[ÛØÚÙ] BTÛY JBRY ÌÍÑ]IÉÝÉ][ÝÉ][ÝÈ[BSÙÐÞ ][ÝÒ[ÈÛHÙ][ÝË ÌÍÑ]JBQ[Y[[ Run the server at the server computer. Change the IP address to the server's ip in the client script and then run it. You can send commands like: ipaddress, username, etc. The script will tell you that info from the server comp. I'm sorry I can't really help you but I'm using someone else's computer. Link to comment Share on other sites More sharing options...
2words4uready Posted August 8, 2008 Author Share Posted August 8, 2008 (edited) Thanks for the reply but i would like someone to tell me whats wrong with the code so that i can fix it. EDIT: Lots of typos Edited August 8, 2008 by 2words4uready Link to comment Share on other sites More sharing options...
Nahuel Posted August 8, 2008 Share Posted August 8, 2008 Well just from looking at it I can find many weird things. Like: Select Case Run($exe2) EndSelect Run($exe2) will always be called. And what is $exe2?? I'm not familiar with the TCPFuncs.au3 include. Have you even tried mine? Just modify it and it'll do what you want. Why close the connection every time? I made some modifications to yours (well, pretty much everything. And now you can run programs at the server and send messages too) SERVER TCPStartUp() $MainSocket = TCPListen(TCPNameToIP(@computername), 7000, 100 ) If $MainSocket = -1 Then Exit While 1 $ConnectedSocket = TCPAccept( $MainSocket) If $ConnectedSocket >= 0 Then msgbox(0,"","connected",1) ExitLoop EndIf Wend While 1 $Message=TCPRecv($ConnectedSocket,2048) Sleep(25) If $Message<>"" Then If StringInStr($Message,"/run") Then $exe2=StringSplit($Message,"/run",1) MsgBox(0,"",$exe2[$exe2[0]]) Run($exe2[$exe2[0]]) ContinueLoop EndIf If StringInStr($Message,"/msg") Then $msg=StringSplit($Message,"/msg",1) MsgBox(0,"Message",$msg[$msg[0]]) EndIf EndIf WEnd Link to comment Share on other sites More sharing options...
2words4uready Posted August 8, 2008 Author Share Posted August 8, 2008 ok i got it! thanks. You will recieve a special spot in the credits of this program 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