Hi,
I have a TCP/IP connection between my robot to a control program running on a PC. The code below runs in a separate semi-static task.
If I physically disconnect the robot (plug out cable), after a while this task crashes on the SocketSend function call shown below.
The socket_status keeps reporting SOCKET_CONNECTED however.
How can I fix/work around this?
Regards,
! --------------------------------------------------------------------------------
! Send status to client.
! --------------------------------------------------------------------------------
TRAP TrapStatus
VAR socketStatus sockStat;
sockStat:=SocketGetStatus(client_socket);
IF sockStat=SOCKET_CONNECTED THEN
! Send status to client.
SocketSend client_socketStr:=Status+ByteToStr(13Char)+ByteToStr(10Char);
ELSE
! Connection lost?
! …
ENDIF
! Acknowledge.
SetDO doStatus,0;
RETURN;
ERROR
!TryNext;
! Acknowledge.
SetDO doStatus,0;
RETURN;
ENDTRAP