Code covered by the BSD License  

Highlights from
TCP/UDP/IP Toolbox 2.0.6

4.6

4.6 | 40 ratings Rate this file 198 Downloads (last 30 days) File Size: 211 KB File ID: #345
image thumbnail

TCP/UDP/IP Toolbox 2.0.6

by

 

13 Mar 2001 (Updated )

TCP/IP connections or UDP packets in MATLAB

Editor's Notes:

TCP/IP connectivity is also included in The MathWorks Instrument Control Toolbox:

http://www.mathworks.com/products/instrument/

| Watch this File

File Information
Description

TCP/UDP/IP Toolbox 2.0.6

Example of remote tcp-ip connection:
    con=pnet('tcpconnect','remote-server.xxx.com',1677);
    pnet(con,'printf','Hello world!\n');
    pnet(con,'close');

This toolbox can be used to set up TCP/IP connections or
send/receive UDP/IP packets in MATLAB. It can transmit data over the Intranet/Internet between MATLAB processes or other applications. It is possible to act as server and/or client and transmit textstrings, arrays of any datatype, files or MATLAB variables.

New in 2.0.6 2008-03-06

  -Included a precompiled pnet.mexw32 for support to in matlab R2007 (R2008?)
   No need to compile pnet.c to run at the R2007 platform.

NEW in 2.0.5

More "proper" license specification makes it possible to be useded as (dynamical) linked extention to non-free stand alones of your MATLAB commercial applications.
The precompiled pnet.dll is possible to run in matlab 5.x for Windows.

NEW in 2.0.4
* THE bug when running at Windows platform is removed.
* pnet_remote can call arrays of slaves with just one call.

NEW in 2.0.3
* Support for the single datatype.

NEW in 2.0.2
* Important Bugfix for UDP support.
* Calls to drawnow makes blocking operations breakable also in windows.

NEW in 2.0.1
* Bugfix for windows version, Sleep() delay is div. with 1000 to correspond to unix sleep().

NEW in 2.0:
* UDP packets.
* FAST Datatype support for int*, uint*, double, char.
* FAST INTERNAL byte swapping.
* UDP/IP-demos.
* TCP/IP-demos.
* WEB-SERVER demo.
* New nonblocking remote "eval" of matlab expression on remote host.
   
Tested to work with MATLAB 5.3/6.x for Linux, Solaris, Windows Compiled mex files for tested platforms included. C-source should compile under any Unix/Windows system. Also basic support for remote evaluation and paralelization of MATLAB is included.

This zip package includes the zip package containing version 1.2.4 with mex files (*.dll) for backward compatibility.

Toolbox by:

Peter Rydesäter
Peter.Rydesater@mh.se

http://www.rydesater.com

With support from Mario Bergeron & Mike Medeiros

Any donations from commercial use are welcome to sponsor this project.

TCP/IP connectivity is also included in The MathWorks Instrument Control Toolbox:

http://www.mathworks.com/products/instrument/

Acknowledgements

This file inspired Prcorr2 10 Times Faster Correlation Coef., Py Udp, and Matirc.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements MATLAB R2007a, R2008a? 5.3 or 6.x. Low level calls probably works in 5.x
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (65)
01 Dec 2014 Yihui

Hello,

I am trying to sending commands from my console via a UDP port to matlab where my instrument is controlled.

When I send a command (as package) from my console, on the matlab side I always have to run 'readpacket' and 'read' to get it.

Is it possible to skip that?

Thanks a lot!

29 Apr 2014 Clayton Chu

Is there a way to select what the source IP should be?

09 Nov 2013 Aleksander

great tool,
how ever i have a couple of issues:
when i do:
pnet_remote(con,'status')

i get:

WAIT FOR CONNECTION ON PORT: 5678
con =
-1
START SERVING NEW CONNECTION FROM IP 0.0.0.0 port:0

also when the i first issue a pnet command at startup i get :

Warning: In the directory "C:\Documents and Settings\Administrator\My
Documents\Dropbox\matlab_new\tcp_udp_ip", pnet.mexw32 now shadows pnet.dll.
Please see the MATLAB 7.1 Release Notes.

11 Jul 2013 Victoria Emberle

Can I somehow use this toolbox for matlab 2006a and if so how? and how do I effectively install the toolbox?

If not, does anyone have suggestions on how I can send udp port signals without having to write a code from scratch... CHeers

31 Jan 2013 amjad ali

can any one help me that how to interlink matlab with gnu radio

16 Apr 2012 Abdu

I can only say that this toolbox is a great service for the world...

15 Dec 2011 JIE

I compiled it successfully on Ubuntu 9.1.
However, it always fail compiling on Ubuntu 10.04.
Anyone tried compiling this on Ubuntu 10.04 or above and succeed?

Thanks

17 Oct 2011 Casper

using the command "mex pnet.c ws2_32.lib" generates an error, and I'm not well-versed enough to find the problem by myself (I'm an intern).

Would it be possible for anyone to upload an x64-version?

01 Jul 2011 Thomas Dautermann

I compiled pnet.c with the Matlab 2011a mex compiler using the visual studio 10 c++ compiler on Windows 7 / 64-bit using the command:

"mex pnet.c ws2_32.lib"

Seems to work fine so far. I also changed line 64 from
#IFDEF WIN32
to
#IFDEF _WIN64

01 Jun 2011 Edgar Guevara  
18 May 2011 Alex Zhang

I believe this problem of Windows 7 has been solved by installing the visual c++ and the SDK together.

18 May 2011 Alex Zhang

Really need help on how to compile this Toolbox PNET.c for 64 Windows 7? Or does this PNET.c need to be ported for windows 64bit?

08 Apr 2011 Leo

I got error message "[recvfrom() or recv()]: WSA error: WSAEMSGSIZE" on UDP receiving. Any suggestions?

20 Jan 2011 Kotya Karapetyan

I wonder if anyone could help me with compiling this at a Windows x64 platform? How do I do it? I am working on Windows 7 and I have never compiled any c-code in my life. Or may be someone just has this pnet compiled for x64?

19 Jan 2011 Kotya Karapetyan  
13 Mar 2010 anon donor

I was able to achieve >512mbps (that's 0.5 gigabit/sec) of read or write by modifying pnet.c as follows, and recompiling the mex extention:

---- edit of pnet.c start here----------------
int tcp_connect(const char *hostname,const int port)
{
+ int optval;
+ int result=0;

if(ipv4_lookup(hostname,port)==-1)
return -1;
con[con_index].fid=socket(AF_INET, SOCK_STREAM, 0);

+ optval=1;
+ result = setsockopt(con[con_index].fid, +IPPROTO_TCP,TCP_NODELAY,(char *) &optval,sizeof(optval));
+ optval = 512*1024;
+ result = setsockopt(con[con_index].fid, SOL_SOCKET,SO_SNDBUF,(char *) &optval,sizeof(optval));
+ result = setsockopt(con[con_index].fid, SOL_SOCKET,SO_RCVBUF,(char *) &optval,sizeof(optval));

---- edit of pnet.c ends here----------------

with the modified pnet, executing pnet read/write calls using a buffer of 512kbytes gave very high throughput.

Thank you very much peter , for contributing this and sharing
the source, it's been very useful.

06 Mar 2010 Igory iBass

If anybody had such wrong like a 'pnet_sendvar bla bla bla', correct youself pnet_putvar M-file.
- Write "pnet_putvar" instead of "pnet_sendvar" on LINE 46.
Enjoy;)

18 Feb 2010 Colin Selleck

Anyone have luck running this under MAC OS 10.6.2 Snow Leopard? It seems to put MATLAB in an infinite busy state.

28 Jan 2010 Christopher Volpe

When the latest version loads,the console output claims that it is version 2.0.5, as that's the version that's hard-coded into pnet.c. Is this merely a cosmetic error?

22 Dec 2009 Georg Stillfried

Kostas Grunder

That did the trick. Thank you very much!

09 Dec 2009 Kostas Grunder

Georg Stillfried

To compile pnet.c under Linux (9.04 Ubuntu) in Matlab 2009b you must make sure the comments // are changed into /* ... */

e.g.:

// Comment Line

into

/* Comment Line */

Than:

mex pnet.c

it only gives me a warning

Warning: You are using gcc version "4.3.3-5ubuntu4)". The earliest gcc version supported
with mex is "4.1". The latest version tested for use with mex is "4.2".
To download a different version of gcc, visit http://gcc.gnu.org

A bit strange but it does compile

02 Dec 2009 Dan

A great application. Just one question ... in the MATLAB version of tcpip in the instrument control toolbox, there is a parameter called 'OutputBufferSize'. There does not seem to be any kind of analogous parameter for this package. Is the OutputBufferSize dynamically sized or is there a fixed value that I should know about? When responding, please consider me to be a beginner when it comes to TCPIP ... a 'tcpip for dummies' response would be appreciated :)

02 Dec 2009 Dan  
25 Nov 2009 Georg Stillfried

I did not manage to compile the c-file pnet.c. I am running Matlab 2009a on a Linux machine with a 2.6.27 kernel and a 4.3.2. gcc compiler. Can anyone help me?

P.S. I recieve the following error messages:

>> mex -O pnet.c

Warning: You are using gcc version "4.3.2". The earliest gcc version supported
with mex is "4.1". The latest version tested for use with mex is "4.2".
To download a different version of gcc, visit http://gcc.gnu.org

pnet.c:104: error: expected identifier or ‘(’ before ‘/’ token
pnet.c:170: error: expected identifier or ‘(’ before ‘/’ token
pnet.c: In function ‘newbuffsize’:

[... many more error messages...]

pnet.c:1158: error: expected expression before ‘/’ token
pnet.c:1174: error: expected expression before ‘/’ token

mex: compile of ' "pnet.c"' failed.

17 Aug 2009 Goola

I want to implement 802.11 MAC layer in matlab
is there anyone who knows any useful and related toolbox or m.file?

12 Jun 2009 Kevin Bartlett

I have created a simple program for sending and receiving UDP packets. It isn't as feature-rich or flexible as the TCP/UDP/IP Toolbox, not having support for TCP packets or able to handle large volumes of data, but it may be sufficient for some applications.

Search the File Exchange for "py_udp".

10 Jun 2009 calvin nevil nayagam

can some one please help me in using this tool box...

22 Apr 2009 Edward

I can't get the program to run. When executing the examples, I get the error message

/PATH_TO_FILE/pnet.mexglx:
symbol mxCreateDoubleMatrix, version libmx.INTERNAL not defined in file libmx.so with link time reference.

An email to the author two weeks ago has not been answered.

21 Apr 2009 Martin

Nice work. Thank you.

27 Mar 2009 Kevin Bartlett

Got errors trying to compile under RedHat:
pnet.c:104: error: expected identifier or ?(? before ?/? token
and so on. Fixed by editing pnet.c to change all "//" comments to the "/* */" comment format (for example, the comment "// Grow...." becomes "/* Grow....*/"). Now udp_send_demo works on Linux to send data to another Linux machine running udp_plotter_demo. Great!

HOWEVER, still can't get my Windows machine to send data to the Linux machine. udp_send_demo creates a variable "udp" with a value of 1 (i.e., a valid socket, I think); then

pnet(udp,'writepacket',host,port)

returns a value of 328 (presumably the number of bytes sent?), but nothing shows up at the Linux machine running udp_plotter_demo. Has anyone else had a similar experience?

18 Dec 2008 Arturo Bandini

thanks!

29 Oct 2008 Imanol Cruz  
29 Oct 2008 Imanol Cruz

Waiting for a manual

19 Sep 2008 Nikola Toljic

Excellent. Thanks.

31 Jul 2008 Francesco Riganti

Excellent functionality, very useful.

16 Apr 2008 Felipe Braga

Excelent package. I have a really simple doubt that maybe you can help me. I can send messages via this socket, I can establish the connection between my client application and the socket but I cannot read the messages sent from my client application to my MATLAB socket. What do I have to do to read and store this information?

Thanks for the help

29 Jan 2008 Stephen Morris

This is an excellent package and covers the basics very well. However, I found it didn't quite cover my needs because I couldn't find a way of generating events (i.e. calling a callback function whenever data becomes available at a port). If there is in fact a way of doing this then the author can correct my comment, but in the meantime I have successfully used a third-party ActiveX control (SocketWrench from Catalyst Software) that provides this functionality for <$100.

23 Jan 2008 Ulrik -

Why pay for something you can get for free :-)

28 Dec 2007 Steven Kolak

MATLAB now directly supports these protocols through the Instrument Control Toolbox. Visit the TCP/IP and UDP web pages for more information and a downloadable MATLAB code example:
http://www.mathworks.com/tcpip
and
http://www.mathworks.com/udp

22 Oct 2007 Jim Tonti

Excellent work! Ran tcpipmex.dll (tcpip -1.2.4 and associated open, read, write, status) without re-compiling under MATLAB V7 under WinXP SP2. This was a real time saver.

11 Sep 2007 CB Williams

Does the trick...

29 Aug 2007 Daniel Hrach  
17 Jul 2007 Andrew Meyer

Tried to compile a similar toolbox on top of winsock sockets with no success..this was exactly what i was looking for!

29 Mar 2007 Arne Solstad

Very nice tool. Found it necessary to recompile for use in Windows XP/Matlab 7.3 and 7.4, but that was very straightforward - just follow instructions in header of pnet.c (one single mex command).

12 Mar 2007 Rousseau Jean-Michel

Very flexible an independant tool.
Thank's

21 Feb 2006 Danish Hashmi

nice tool

04 Jan 2006 Ravi Paike

Excellent Tool. Thanks

10 Aug 2005 hui lei

thanks

04 Apr 2005 furkan turkmen

good job..

12 Jan 2005 chow wai theng

Can I use it to connect to IIS on Windows 2000 and exchange variables or parameters (in string or text) to my ASP page?
Can it functions like a Web Server connection?

07 Jan 2005 marc frown

there is no sendvar file in the zip file i downloaded
any help?
Thanks

28 Dec 2004 Frans Cornelissen

This toolbox will compile fine and work perfectly on mac os X as is. Yeah! Tested with matlab 7.0.1. on 10.3.2. Just use the mex command with the main pnet.c file and it will generate a pnet.mexmac.

24 Jun 2004 Jesus Lopez

I was looking for a way to do TCP/IP communication over MATLAB and this toolbox gave me the solution I needed.
Maybe it's necessary to improve the documentation and to add some examples.

16 Mar 2004 nick werle

hackers cryptic unusable code is worth what you pay for it.

SW engineering is not doing 1 line of APL code that noone can maintain

17 Oct 2003 ren wei

it is a remarkable work and just meet my needs.But there is something wrong when i tried to 'close' a connection, for the server showed 'busy' even if a command "pnet_remoet(con,'close')" was done in the workspace of a client . waiting for the answers! thank you !

12 Aug 2003 alex keuch

Exactly what i was looking for. Thank's a lot.

26 Jul 2003 Merrill McKee

Wonderful. Thanks.

30 Apr 2003 Arne Solstad

Excellent functionality, and easy to use. Nice work!

31 Mar 2003 Jeff Shafer

Very nice package with good documentation. Many thanks!

03 Feb 2003 Oki Gun

Great - Just What I'm looking for

18 Dec 2002 Mejía C. José Alfonso

All articles are importants & necessary for mi, the problem its on englihs, thanks you. I´m studing Biomedical engineer on México, D.F., Sorry for my bad english, by.

16 Nov 2002 Doug Harriman

Excellent functionality, very useful.

29 Mar 2002 Sacit M. Cetiner

Very sound design; fills a great gap that MathWorks neglects for years.

Can be easily used for both TCP and UDP with a tiny change in command line.

19 Jan 2002  
24 Oct 2001 Veit-Stefan Kafka

A very useful tool for interprocess communication. Sorringly there is no windows-dll included in the actual version (1.2), and the .c-file doesn't compile for me with lcc, so I have to use the linux-version ;-)

Updates

desc

28 Feb 2002

Major improvemet of implementation.
i.e. UDP support.

01 Mar 2002

1.2->2.0, new udp support, much faster, datatype support.
2.0->2.0.1 Bugfix Windows: Sleep() changed.

12 Mar 2002

UDP support more stable (random) parameter is now initialized.
Regular Calls to drawnow makes blocking operations breakable in windows.

23 Jul 2003

major bug fix for Windows platform. THE bug is found. Data is now also transmitted in binary mode at windows platform.

17 Sep 2003

More "proper" license specification makes it possible to be useded as (dynamical) linked extention to non-free stand alones of your MATLAB applications. The precompiled pnet.dll is possible to run in matlab 5.x for Windows.

Contact us