Hi Everyone,
Looking for some genuine help - regarding sockets - and tring to communicate with a 3rd Party Windows Process.
Basically, I'm trying to control a motor.
I created a small test app in AGK.. which is working to a point.
Once the Process has started I need to wait for it to initialise the hardware / motor etc.. and retrun an "idle" state ( a string )
1. I start the 3rd Party API process.. RunApp ( "motor_controller.exe", " " ) - no parameters are passed..
2. I setup a socket - 127.0.0.1 : 3300 - ( Local Host on port 3300 ) connects to the process fine ( tested by commenting out the RunApp etc )
3. Once connected every second or so.. try to read a string from the socket ( merely just to display some communication )..
I test for GetSocketBytesAvailable from Socket before reading the string..
if( socket_status <> SOCKET_CONN )
Select GetSocketConnected( SocketID )
Case -1:
update_status_display( "FAILED TO CONNECT")
socket_status = SOCKET_FAIL
EndCase
Case 0:
update_status_display( "CONNECTING... PLEASE WAIT" )
socket_status = SOCKET_WAIT
EndCase
Case 1:
update_status_display( "CONNECTED" )
socket_status = SOCKET_CONN
EndCase
EndSelect
endif
if( socket_status = SOCKET_CONN )
if( Timer() > response_timer )
response_timer = ( Timer() + 1.0 )
if( GetSocketBytesAvailable( SocketID ) > 0 )
update_response_display( GetSocketString( SocketID ) )
endif
endif
endif
Print( ScreenFPS() )
Sync()
But only when I terminate the 3rd Party Windows Process ( via Task Manager ) - do I receive anything from the socket.
In discussion, the 3rd Party programmer has said the socket should be event driven, not checked every second.
Any pointers would help!
Thanks