MATLAB Answers

Difference between tcpclient and tcpip?

100 ビュー (過去 30 日間)
Christian D
Christian D 2016 年 5 月 9 日
回答済み: Dev-iL 2016 年 5 月 17 日
Hi folks,
What is the difference between tcpclient provided by the standard Matlab and tpcip provided by the Intrument control toolbox? I don't have that toolbox and want to communicate with a device over tcp (sending commands and recieving measurement values). I'm still not aware of the difference of both functions.
Regards, Christian

回答 (3 件)

srj4anoop
srj4anoop 2016 年 5 月 12 日
Hi Christian,
With the tcpclient() function you can only create a TCP/IP client object. The syntax of using tcpclient() is as shown below :
>> tclient = tcpclient('Address',Port,'Timeout',<timeout_value>)
where the Timeout property specifies the waiting time to complete read and write operations in seconds, and the default is 10.
Whereas the tcpip() function lets you create a TCP/IP object that can be configured to work as a Server or as a Client using its NetworkRole property.
For example, to create a TCP/IP server object:
tcpipServer = tcpip('0.0.0.0',55000,'NetworkRole','Server');
and to create a TCP/IP client interface for the server socket:
tcpipClient = tcpip('127.0.0.1',55000,'NetworkRole','Client')
You can refer to the following blog to undertsand more about this function:

Walter Roberson
Walter Roberson 2016 年 5 月 12 日
You might also be interested in the File Exchange contribution "tcpudpip"

Dev-iL
Dev-iL 2016 年 5 月 17 日
  • tcpip can act both as a client and a server, requires the Instrument Control Toolbox and was last modified in R2011a.
  • tcpclient can only act as a client, doesn't require additional toolboxes (as far as I can tell) and was introduced later, that is in R2014b.

Community Treasure Hunt

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

Start Hunting!

Translated by