On top of that, there's no return value (read/write), can't know if anything succeeded or the socket is valid, buggy when used with persistent/global, not sure when exceptions are thrown, and so on.
The whole thing was written by an amateur (and nothing useful from matlab support). My solution: I wrote my own c++ tcp client using mlx--easiest for simple things (but you can also write mex):
https://au.mathworks.com/matlabcentral/answers/1731480-mlx-pass-a-sparse-matrix