I'm trying to connect two instances of Matlab on separate computers using tcp/ip (I was previously using UDP, but ran into some fairly intractable problems arising from UDP's unreliability). When I open either program, I get the error "connection refused: connect." when the TCP/IP object is opened via fopen.
I realize that TCP/IP requires that a connection be established before data can be sent, but I don't know how I can establish this connection if both sides of the connection need to be open for this to happen. It there some step that I am missing here?
Code of the following form is in both programs:
obj = tcpip('*ip address*','RemotePort',8866,'LocalPort',8844)
fopen(obj)
Thanks!
Hi Jonas,
Unfortunately, you cannot use the TCPIP interface to connect two instances
of MATLAB at this time. The TCPIP interface currently only supports the
connection instigation side required of a TCPIP connection. Adding support
to the TCPIP interface which enables listening for connections is a popular
request being considered.
The binding of local ports as you are trying to do above is a UDP specific
solution only possible because UDP connections are stateless unlike TCPIP.
Are you using TCP from the Instrument Control Toolbox, or are you using TCP
from the tcpudpip Matlab File Exchange (FEX) ?
According to Mathworks staffers, the Instrument Control Toolbox cannot act as
a TCP server. The reason given has to do with not being able to bind a local
port to receive a connection -- no equivalent of the POSIX standard listen() call.
I do not know if the FEX contribution has the same limit; I have not looked at
the set of functions it provides.
> (I was previously using UDP, but ran into some fairly
> intractable problems arising from UDP's unreliability)
In theory TCP can be built on top of UDP, but it is a pain to do!
FYI, I'm using the instrument control toolbox TCP/IP object.