diveboy Posted February 18, 2008 Posted February 18, 2008 AS per my previous post. I'm writing a client that needs to query a server for a command, which can be one of three options, sleep, new build, old build, this is for a migration to a new netware environment. I have hacked this from the examples and it's flaky at best when it does work. I need to have a program running on a machine acting as a server, this has to send a command apon connection from the clients. Server code CODE#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 447, 193, 125) $Radio1 = GUICtrlCreateRadio("Sleep", 40, 24, 137, 25) $Radio2 = GUICtrlCreateRadio("New Build", 40, 56, 129, 17) $Radio3 = GUICtrlCreateRadio("Old Build", 40, 72, 137, 41) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;SERVER!! Start Me First !!!!!!!!!!!!!!! $g_IP = @IPAddress1 $buildcommand = "Sleep" ; Start The TCP Services ;============================================== TCPStartUp() msgbox(0,"Build Command", $buildcommand) ; Create a Listening "SOCKET" ;============================================== $MainSocket = TCPListen($g_IP, 65432, 100 ) If $MainSocket = -1 Then Exit ; look for client connection ;-------------------- While 1 $ConnectedSocket = TCPAccept( $MainSocket) If $ConnectedSocket >= 0 Then TCPSend($ConnectedSocket,$buildcommand) TCPCloseSocket ($ConnectedSocket) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $radio1 $buildcommand = "Sleep" Case $radio2 $buildcommand = "New Build" Case $radio3 $buildcommand = "Old Build" Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Client code CODE$g_IP = @IPAddress1 ; Start The TCP Services ;============================================== TCPStartUp() ; Create a Listening "SOCKET" ;============================================== ; look for client connection ;-------------------- While 1 ;If $ConnectedSocket >= 0 Then ;$MainSocket $MainSocket = TCPConnect ($g_IP, 65432) ;If $MainSocket = -1 Then Exit $recv = TCPRecv( $MainSocket, 9) msgbox(0,'Build Command',$recv,2 ) TCPCloseSocket ($MainSocket) ;msgbox(0,"","my server - Client Connected") ;exit sleep(5000) ;EndIf Wend basically, it should work but doesn't. All I want it to do is connect to the server machine, find out what the command is and then go from there. I just can't seem to get it working properly. any assistance would be great Thanks in advance Michael.
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