About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
  • Last update: 5 years ago
  • Total downloads: 14
  • Operating system: Linux, Mac OS X, Win All, BSD, Solaris
  • Publisher: Jude Collins
See full specifications

scripts default iconmatSock (Scripts) Publisher's description

non blocking tcpip event based sockets for Matlab.

non blocking tcpip event based sockets for Matlab.
A small java class that implements a channel multiplexor in a separate thread and allows you to register socket connections and Matlab callback functions for socket channel events (OP_READ, OP_WRITE, OP_ACCEPT, OP_CONNECT). Leaves the command prompt available for you to keep working while it runs in the background. The SocketChannel that causes the event is passed into the Matlab callback in the event data. There is no need to open multiple instances of Matlab to test it. I have included an echo server for testing.

I get data rates >100Mbps.


% open a connection to something, set blocking to false
% see the channelConnect() mfile for more details.
clientChannel = channelConnect(hostName, portNum, soRcvBuffSize, soSndBuffSize, tcpNoDelay, blocking);

% The default behavior of the non-blocking sockets is to fire
% a read event as soon as any data is read. This results in
% data segmentation that must be handled in Matlab. If you
% intialize the SocketManager with a byteOffset (zero indexed)
% to the location of an int32 that gives the size of the message
% the bytes will be collected until the full message is received
% and then it will be sent. (Generally this would be a value
% included in the data header).
% In the case below it expects the int32
% at bytes 4-7 (zero indexed) to tell the total message size.
socketManager = SocketManager(4);

% registers clientChannel OP_READ events

% register a Matlab callback for read events

% echoServerTestBuffer generates
request = echoServerTestBuffer();
len = channelWrite(clientChannel, request);

% onReceive will fire whenever data is waiting to
% be read on clientChannel

For a complete example see "main.m" in the attached files.

The echo server constructor can take one argument which is a
port number.

You will need to edit your "classpath.txt" (type 'edit classpath.txt' at the matlab command prompt) and add the path to the bin directory that contains the java classes from the zip file.

It should look something like this when you are done:

You then MUST restart Matlab.

The class files were built on my Windows 32 bit machine against Java 1.5.0_07.

This submission was inspired by my job and enabled by the useful information on UndocumentedMatlab.com. Particularly this post:

I hope to flesh this out a little more soon,make it a little more user friendly, and add some nice documentation. The functionality for OP_ACCEPT for server sockets is not fully implemented yet although the callback is visible. Do not use it.

System Requirements:

No special requirements.
Program Release Status: New Release
Program Install Support: Install and Uninstall

matSock (Scripts) Tags:

Click on a tag to find related softwares

Is matSock (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.