Hello,
I've got a small problem:
I'm using socket messaging to send simple commands from/to the robot from/to an IPC. The good news: Socket messaging is working, everything is fine if a client is connected. And here is my problem:
The program is waiting in the line "MSG_CONNECT('S3',STATUS)" until a client is trying to connect. Now I've got the that case, that the client on the IPC is crashing or not available due to older software revisions (without or with a buggy client on the IPC). The server program is a background task so that it's started with the control of the robot.
The server program can not be overwritten while it is running. But it is running always and waiting for a client which will never connect. Our service technicians are not able to shut down such programs because they don't know how to shut down background programs at all. They are able to copy files from A to B, that's all. And i don't want to tell them that much about the programs: The more they try to do on their own, the more mistakes they will do.
So I'm looking for a simple solution to shut down my server program. If the client is connected, the program has a main while() loop with exit conditions (just a flag).
I think there are 2 solutions:
1)
MSG_CONNECT and timeout. If MSG_CONNECT is just trying to connect for 30 seconds, the technicians would be able to set a FLAG=TRUE and then they wait 30 seconds.
Example:
exitServer=FALSE
serverOn=FALSE
WHILE exitServer=FALSE DO
-- need some timeout here!
-- max time for MSG_CONNECT=30 seconds or something like that.
MSG_CONNECT('S3:', STATUS)
IF STATUS = 0 THEN
WRITE('Connection Established', CR)
serverOn=TRUE
WHILE serverOn=TRUE DO
DELAY(200)
--...do some stuff
ENDWHILE
ELSE
WRITE('Connection error', CR)
ENDIF
exit=FLG[2]
DELAY(500)
ENDWHILE
Display More
If MSG_CONNECT would try to connect for 30 seconds, this loop can be canceled by setting FLG[2]=TRUE and waiting up to 30seconds.
Is this possible?
I tried the FILE_ATTRIBUE ATR_TIMEOUT, but this is only useful for the established connection.
2)
Another background program which is running parallel to my server program. This program is quite simple:
But there are 2 problems:
a) i don't know how to kill another background task or any other program which has been started by "RUN".
b) i would like to avoid having more background programs. But if this is the only solution....?!