image thumbnail

jtcp(actionStr,vara​rgin)

version 1.12.0.0 (20.2 KB) by Kevin Bartlett
Sends/receives TCP packets using Matlab's Java interface. Now handles matrices and cell arrays, etc.

16.4K Downloads

Updated 27 Mar 2017

View License

Transmission Control Protocol (TCP/IP) communications are used to send data from one computer to another over a network or from one application to another within a single computer.
The jtcp.m program uses Matlab's ability to call Java code to enable it to send and/or receive TCP packets. One Matlab session can communicate with another Matlab session (on the same machine or over the network) or it can communicate with a completely different program (again, on the same machine or over the network).
This latest version of jtcp.m uses Java's serialization functionality to write and read strings, matrices, cell arrays and primitives (that is, just about any Matlab variable type other than structures).

Serialization will cause errors if jtcp.m is talking to a program or piece of hardware that does not itself implement serialization. In this case, set the 'serialize' argument to false when requesting or accepting a connection. This will limit read and write operations to variables of type "int8", which most socket applications will be able to handle.

Update, 2013-04-19 (thanks to Qi Wang for pointing this out): java.lang.OutOfMemoryError occurs after a volume of data approximating the Java heap space size has been sent. This appears to be a bug in Java itself (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6525563). Workaround is to call
jTcpObj.outputStream.reset;
every once in a while from whatever program you are calling the jtcp "WRITE" command from.

Cite As

Kevin Bartlett (2021). jtcp(actionStr,varargin) (https://www.mathworks.com/matlabcentral/fileexchange/24524-jtcp-actionstr-varargin), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!