To Block, or not to Block …
The methods of the tcpsocket type do not block in SIMPOL. However, if no
timeout
is specified then the default value of .inf
will result in the operation never exiting. When waiting on data using either of the receive methods if no data
ever arrives the program will wait forever (or until the socket closes). It is far better to control this in the
program by setting a timeout value and using it as the optimum time to exit if nothing happens. By placing the
receive operation in a loop, the program can continue to loop until no data is received within the allotted
timeout period. At that point the program can exit, or in the case of a GUI-style program it can ask the user
whether to retry or cancel, etc.