Azzera filtri
Azzera filtri

Timeout when running tcpip in server mode OR how to force fopen to return after a set timeout

1 visualizzazione (ultimi 30 giorni)
Hello all,
I found and was playing with Matlab's ability to act as tcpip server:
t = tcpip('localhost',30000,'NetworkRole','server')
I can then use this connection to send files between Matlab instances (such as me and my lab mate). However, fopen does not return until a connection has been made by someone. While I can ctrl-C to get out of this, you cannot ctrl-C in a deployed application AND this drops us out of the entire program rather than letting us skip this step and move on with other operations. Nominally I would want a connection timeout option for the tcpip object, but there is no such property or method.
So, I can see 3 possible options,
  • Run fopen asynchronously so that even if it is sitting there waiting till the dawn of time, the rest of my code can continue to execute.
  • Run fopen with some sort of timeout enforced externally during the call (something like FEX timeout, but not using ctrl-C. I just want to force the fopen command to return after a reasonable period).
  • Modify tcpip itself to allow for a timeout.
The middle is my favorite, since I can use that for other code. Any ideas?

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by